-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6607959
commit 50fe438
Showing
15 changed files
with
445 additions
and
698 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -576,10 +576,10 @@ | |
"@types/istanbul-lib-coverage" "*" | ||
"@types/istanbul-lib-report" "*" | ||
|
||
"@types/[email protected].2": | ||
version "25.1.2" | ||
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-25.1.2.tgz#1c4c8770c27906c7d8def5d2033df9dbd39f60da" | ||
integrity sha512-EsPIgEsonlXmYV7GzUqcvORsSS9Gqxw/OvkGwHfAdpjduNRxMlhsav0O5Kb0zijc/eXSO/uW6SJt9nwull8AUQ== | ||
"@types/[email protected].3": | ||
version "25.1.3" | ||
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-25.1.3.tgz#9b0b5addebccfb631175870be8ba62182f1bc35a" | ||
integrity sha512-jqargqzyJWgWAJCXX96LBGR/Ei7wQcZBvRv0PLEu9ZByMfcs23keUJrKv9FMR6YZf9YCbfqDqgmY+JUBsnqhrg== | ||
dependencies: | ||
jest-diff "^25.1.0" | ||
pretty-format "^25.1.0" | ||
|
@@ -7194,10 +7194,10 @@ trim-newlines@^2.0.0: | |
resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-2.0.0.tgz#b403d0b91be50c331dfc4b82eeceb22c3de16d20" | ||
integrity sha1-tAPQuRvlDDMd/EuC7s6yLD3hbSA= | ||
|
||
[email protected].0: | ||
version "25.2.0" | ||
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-25.2.0.tgz#dfd87c2b71ef4867f5a0a44f40cb9c67e02991ac" | ||
integrity sha512-VaRdb0da46eorLfuHEFf0G3d+jeREcV+Wb/SvW71S4y9Oe8SHWU+m1WY/3RaMknrBsnvmVH0/rRjT8dkgeffNQ== | ||
[email protected].1: | ||
version "25.2.1" | ||
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-25.2.1.tgz#49bf05da26a8b7fbfbc36b4ae2fcdc2fef35c85d" | ||
integrity sha512-TnntkEEjuXq/Gxpw7xToarmHbAafgCaAzOpnajnFC6jI7oo1trMzAHA04eWpc3MhV6+yvhE8uUBAmN+teRJh0A== | ||
dependencies: | ||
bs-logger "0.x" | ||
buffer-from "1.x" | ||
|
@@ -7208,7 +7208,7 @@ [email protected]: | |
mkdirp "0.x" | ||
resolve "1.x" | ||
semver "^5.5" | ||
yargs-parser "10.x" | ||
yargs-parser "^16.1.0" | ||
|
||
[email protected]: | ||
version "6.2.1" | ||
|
@@ -7306,10 +7306,10 @@ typedarray@^0.0.6: | |
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" | ||
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= | ||
|
||
typescript@3.7.5: | ||
version "3.7.5" | ||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.5.tgz#0692e21f65fd4108b9330238aac11dd2e177a1ae" | ||
integrity sha512-/P5lkRXkWHNAbcJIiHPfRoKqyd7bsyCma1hZNUGfn20qm64T6ZBlrzprymeu918H+mB/0rIg2gGK/BXkhhYgBw== | ||
typescript@3.8.2: | ||
version "3.8.2" | ||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.8.2.tgz#91d6868aaead7da74f493c553aeff76c0c0b1d5a" | ||
integrity sha512-EgOVgL/4xfVrCMbhYKUQTdF37SQn4Iw73H5BgCrF1Abdun7Kwy/QZsE/ssAy0y4LxBbvua3PIbFsbRczWWnDdQ== | ||
|
||
[email protected]: | ||
version "3.4.10" | ||
|
@@ -7819,7 +7819,7 @@ yallist@^3.0.2: | |
resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" | ||
integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== | ||
|
||
yargs-parser@10.x, yargs-parser@^10.0.0: | ||
yargs-parser@^10.0.0: | ||
version "10.1.0" | ||
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-10.1.0.tgz#7202265b89f7e9e9f2e5765e0fe735a905edbaa8" | ||
integrity sha512-VCIyR1wJoEBZUqk5PA+oOBF6ypbwh5aNB3I50guxAL/quggdfs4TtNHQrSazFA3fYZ+tEqfs0zIGlv0c/rgjbQ== | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.Collections.Generic; | ||
using System.Net; | ||
|
||
namespace WebTty.Hosting | ||
{ | ||
public class WebTtyHostOptions | ||
{ | ||
public IPAddress Address { get; set; } = IPAddress.Loopback; | ||
public string UnixSocket { get; set; } | ||
public int Port { get; set; } = 5000; | ||
public string Path { get; set; } = "/pty"; | ||
public string Theme { get; set; } = "default"; | ||
public string Command { get; set; } | ||
public List<string> Args { get; set; } = new List<string>(); | ||
|
||
internal IDictionary<string, string> ToDictionary() | ||
{ | ||
return new Dictionary<string, string> | ||
{ | ||
{ nameof(Address), Address.ToString() }, | ||
{ "UnixSocket", UnixSocket }, | ||
{ "Port", Port.ToString() }, | ||
{ "Path", Path }, | ||
{ "Theme", Theme }, | ||
{ nameof(Command), Command }, | ||
{ nameof(Args), string.Join(' ', Args) }, | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using System; | ||
using System.CommandLine; | ||
using System.CommandLine.Parsing; | ||
using System.Linq; | ||
using System.Net; | ||
|
||
namespace WebTty | ||
{ | ||
public static class ArgumentExtensions | ||
{ | ||
public static bool TryConvertIPAddress(SymbolResult result, out IPAddress address) | ||
{ | ||
var token = result.Tokens.FirstOrDefault(); | ||
|
||
if (string.Equals("localhost", token.Value, StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
address = IPAddress.Loopback; | ||
return true; | ||
} | ||
|
||
if (string.Equals("any", token.Value, StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
address = IPAddress.Any; | ||
return true; | ||
} | ||
|
||
return IPAddress.TryParse(token.Value, out address); | ||
} | ||
|
||
public static Argument<string> StartsWith(this Argument<string> arg, char character) | ||
{ | ||
arg.AddValidator(result => { | ||
var value = result.GetValueOrDefault<string>(); | ||
return value.StartsWith(character) ? | ||
string.Empty : $"Argument {result.Argument.Name} should start with a {character}."; | ||
}); | ||
|
||
return arg; | ||
} | ||
|
||
public static Argument<int> Between(this Argument<int> args, int min, int max) | ||
{ | ||
args.AddValidator(result => { | ||
int port; | ||
|
||
try | ||
{ | ||
port = result.GetValueOrDefault<int>(); | ||
} | ||
catch | ||
{ | ||
return $"Argument {result.Argument.Name} should be an integer."; | ||
} | ||
|
||
return port > min && port < max ? | ||
string.Empty : $"Argument {result.Argument.Name} should be a value between {min} and {max}."; | ||
}); | ||
|
||
return args; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.