Update CLI

Signed-off-by: jolheiser <john.olheiser@gmail.com>
This commit is contained in:
jolheiser 2020-11-04 22:39:42 -06:00
parent 04ad1997a6
commit c2487d8f92
No known key found for this signature in database
GPG key ID: B853ADA5DA7BBF7A
3 changed files with 30 additions and 20 deletions

3
go.mod
View file

@ -3,12 +3,13 @@ module github.com/schollz/hostyoself
go 1.12
require (
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
github.com/fsnotify/fsnotify v1.4.7
github.com/gorilla/websocket v1.4.0
github.com/h2non/filetype v1.0.8
github.com/jteeuwen/go-bindata v3.0.7+incompatible // indirect
github.com/schollz/logger v1.0.1
github.com/urfave/cli v1.20.0
github.com/urfave/cli/v2 v2.3.0
github.com/vincent-petithory/dataurl v0.0.0-20160330182126-9a301d65acbb
golang.org/x/sys v0.0.0-20190710143415-6ec70d6a5542 // indirect
)

17
go.sum
View file

@ -1,3 +1,8 @@
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
@ -6,11 +11,19 @@ github.com/h2non/filetype v1.0.8 h1:le8gpf+FQA0/DlDABbtisA1KiTS0Xi+YSC/E8yY3Y14=
github.com/h2non/filetype v1.0.8/go.mod h1:isekKqOuhMj+s/7r3rIeTErIRy4Rub5uBWHfvMusLMU=
github.com/jteeuwen/go-bindata v3.0.7+incompatible h1:91Uy4d9SYVr1kyTJ15wJsog+esAZZl7JmEfTkwmhJts=
github.com/jteeuwen/go-bindata v3.0.7+incompatible/go.mod h1:JVvhzYOiGBnFSYRyV00iY8q7/0PThjIYav1p9h5dmKs=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/schollz/logger v1.0.1 h1:BuBAU+euqphM0Ny9qFVScl4RSxatis4nCHIkOxO2cUU=
github.com/schollz/logger v1.0.1/go.mod h1:P6F4/dGMGcx8wh+kG1zrNEd4vnNpEBY/mwEMd/vn6AM=
github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/vincent-petithory/dataurl v0.0.0-20160330182126-9a301d65acbb h1:lyL3z7vYwTWXf4/bI+A01+cCSnfhKIBhy+SQ46Z/ml8=
github.com/vincent-petithory/dataurl v0.0.0-20160330182126-9a301d65acbb/go.mod h1:FHafX5vmDzyP+1CQATJn7WFKc9CvnvxyvZy6I1MrG/U=
golang.org/x/sys v0.0.0-20190710143415-6ec70d6a5542 h1:6ZQFf1D2YYDDI7eSwW8adlkkavTB9sw5I24FVtEvNUQ=
golang.org/x/sys v0.0.0-20190710143415-6ec70d6a5542/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

30
main.go
View file

@ -14,7 +14,7 @@ import (
"github.com/schollz/hostyoself/pkg/client"
"github.com/schollz/hostyoself/pkg/server"
log "github.com/schollz/logger"
"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)
func init() {
@ -35,19 +35,17 @@ func main() {
app.Compiled = time.Now()
app.Usage = "host your files using websockets from the command line or a browser"
app.UsageText = "use to transfer files or host an impromptu website"
app.Commands = []cli.Command{
app.Commands = []*cli.Command{
{
Name: "relay",
Usage: "start a relay",
Description: "relay is used to transit files",
Flags: []cli.Flag{
cli.StringFlag{Name: "url, u", Value: "localhost", Usage: "public URL to use"},
cli.StringFlag{Name: "port", Value: "8010", Usage: "ports of the local relay"},
&cli.StringFlag{Name: "url", Aliases: []string{"u"}, Value: "localhost", Usage: "public URL to use"},
&cli.StringFlag{Name: "port", Aliases: []string{"p"}, Value: "8010", Usage: "ports of the local relay"},
},
HelpName: "hostyoself relay",
Action: func(c *cli.Context) error {
return relay(c)
},
Action: relay,
},
{
Name: "host",
@ -55,18 +53,16 @@ func main() {
Description: "host files from your computer",
HelpName: "hostyoself relay",
Flags: []cli.Flag{
cli.StringFlag{Name: "url, u", Value: "https://hostyoself.com", Usage: "URL of relay to connect"},
cli.StringFlag{Name: "domain, d", Value: "", Usage: "domain to use (default is random)"},
cli.StringFlag{Name: "key, k", Value: "", Usage: "key value to use (default is random)"},
cli.StringFlag{Name: "folder, f", Value: ".", Usage: "folder to serve files"},
},
Action: func(c *cli.Context) error {
return host(c)
&cli.StringFlag{Name: "url", Aliases: []string{"u"}, Value: "https://hostyoself.com", Usage: "URL of relay to connect"},
&cli.StringFlag{Name: "domain", Aliases: []string{"d"}, Usage: "domain to use (default is random)"},
&cli.StringFlag{Name: "key", Aliases: []string{"k"}, Usage: "key value to use (default is random)"},
&cli.StringFlag{Name: "folder", Aliases: []string{"f"}, Value: ".", Usage: "folder to serve files"},
},
Action: host,
},
}
app.Flags = []cli.Flag{
cli.BoolFlag{Name: "debug", Usage: "increase verbosity"},
&cli.BoolFlag{Name: "debug", Usage: "increase verbosity"},
}
app.EnableBashCompletion = true
app.HideHelp = false
@ -82,7 +78,7 @@ func main() {
}
func host(c *cli.Context) (err error) {
if c.GlobalBool("debug") {
if c.Bool("debug") {
log.SetLevel("debug")
} else {
log.SetLevel("info")
@ -104,7 +100,7 @@ func host(c *cli.Context) (err error) {
}
func relay(c *cli.Context) (err error) {
if c.GlobalBool("debug") {
if c.Bool("debug") {
log.SetLevel("debug")
} else {
log.SetLevel("info")