-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- [*] regulate main dispatcher name too
- Loading branch information
Showing
4 changed files
with
35 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ var root = &cli.Command{ | |
{{if .Global}} Global: {{.Global}}, | ||
{{end}}{{if .Self}} Argv: func() interface{} { t := new(rootT); t.Self = t; return t }, | ||
{{else}} Argv: func() interface{} { return new(rootT) }, | ||
{{end}} Fn: {{.Name}}, | ||
{{end}} Fn: {{clk2uc .Name}}, | ||
{{if .NumOption}} | ||
NumOption: {{.NumOption}}, | ||
{{end}}{{if .NumArg}} | ||
|
@@ -74,9 +74,7 @@ var root = &cli.Command{ | |
|
||
// Function main | ||
// func main() { | ||
// cli.SetUsageStyle({{or .Style "cli.DenseNormalStyle"}}) // left-right, for up-down, use ManualStyle | ||
// //NOTE: You can set any writer implements io.Writer | ||
// // default writer is os.Stdout | ||
// cli.SetUsageStyle({{or .Style "cli.DenseNormalStyle"}}) | ||
// if err := cli.Root(root,{{range $i, $cmd := .Command}} | ||
// cli.Tree({{$cmd.Name}}Def){{if lt $i ($.Command | len | minus1)}},{{end}}{{end}}).Run(os.Args[1:]); err != nil { | ||
// fmt.Fprintln(os.Stderr, err) | ||
|
@@ -89,7 +87,8 @@ var root = &cli.Command{ | |
//========================================================================== | ||
// Dumb root handler | ||
|
||
// func {{.Name}}(ctx *cli.Context) error { | ||
// {{clk2uc .Name}} - main dispatcher dumb handler | ||
// func {{clk2uc .Name}}(ctx *cli.Context) error { | ||
// ctx.JSON(ctx.RootArgv()) | ||
// ctx.JSON(ctx.Argv()) | ||
// fmt.Println() | ||
|
@@ -116,11 +115,11 @@ var root = &cli.Command{ | |
// | ||
// Do{{stringsTitle .Name}} implements the business logic of command `{{.Name}}` | ||
// func Do{{stringsTitle .Name}}() error { | ||
// fmt.Fprintf(os.Stderr, | ||
// "%s v%s {{.Name}} - {{.Desc}}\n", | ||
// progname, version) | ||
// fmt.Fprintf(os.Stderr, "{{.Desc}}\n") | ||
// // fmt.Fprintf(os.Stderr, "Copyright (C) {{ date "Y4" }}, {{or $.Authors "The Author(s) <[email protected]>"}}\n\n") | ||
// // err := ... | ||
// // clis.WarnOn("Doing {{stringsTitle .Name}}", err) | ||
// // or, | ||
// // clis.AbortOn("Doing {{stringsTitle .Name}}", err) | ||
// return nil | ||
// } | ||
|
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 |
---|---|---|
|
@@ -34,7 +34,7 @@ var root = &cli.Command{ | |
{{if .Global}} Global: {{.Global}}, | ||
{{end}}{{if .Self}} Argv: func() interface{} { t := new(rootT); t.Self = t; return t }, | ||
{{else}} Argv: func() interface{} { return new(rootT) }, | ||
{{end}} Fn: {{.Name}}, | ||
{{end}} Fn: {{clk2uc .Name}}, | ||
{{if .NumOption}} | ||
NumOption: {{.NumOption}}, | ||
{{end}}{{if .NumArg}} | ||
|
@@ -72,9 +72,7 @@ var root = &cli.Command{ | |
|
||
// Function main | ||
// func main() { | ||
// cli.SetUsageStyle({{or .Style "cli.DenseNormalStyle"}}) // left-right, for up-down, use ManualStyle | ||
// //NOTE: You can set any writer implements io.Writer | ||
// // default writer is os.Stdout | ||
// cli.SetUsageStyle({{or .Style "cli.DenseNormalStyle"}}) | ||
// if err := cli.Root(root,{{range $i, $cmd := .Command}} | ||
// cli.Tree({{$cmd.Name}}Def){{if lt $i ($.Command | len | minus1)}},{{end}}{{end}}).Run(os.Args[1:]); err != nil { | ||
// fmt.Fprintln(os.Stderr, err) | ||
|
@@ -87,7 +85,8 @@ var root = &cli.Command{ | |
//========================================================================== | ||
// Dumb root handler | ||
|
||
// func {{.Name}}(ctx *cli.Context) error { | ||
// {{clk2uc .Name}} - main dispatcher dumb handler | ||
// func {{clk2uc .Name}}(ctx *cli.Context) error { | ||
// ctx.JSON(ctx.RootArgv()) | ||
// ctx.JSON(ctx.Argv()) | ||
// fmt.Println() | ||
|
@@ -114,11 +113,11 @@ var root = &cli.Command{ | |
// | ||
// Do{{stringsTitle .Name}} implements the business logic of command `{{.Name}}` | ||
// func Do{{stringsTitle .Name}}() error { | ||
// fmt.Fprintf(os.Stderr, | ||
// "%s v%s {{.Name}} - {{.Desc}}\n", | ||
// progname, version) | ||
// fmt.Fprintf(os.Stderr, "{{.Desc}}\n") | ||
// // fmt.Fprintf(os.Stderr, "Copyright (C) {{ date "Y4" }}, {{or $.Authors "The Author(s) <[email protected]>"}}\n\n") | ||
// // err := ... | ||
// // clis.WarnOn("Doing {{stringsTitle .Name}}", err) | ||
// // or, | ||
// // clis.AbortOn("Doing {{stringsTitle .Name}}", err) | ||
// return nil | ||
// } | ||
|
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
//////////////////////////////////////////////////////////////////////////// | ||
// Program: wireframe | ||
// Purpose: wire framing | ||
// Authors: Myself <[email protected]> (c) 2019, All rights reserved | ||
// Authors: Myself <[email protected]> (c) 2021, All rights reserved | ||
//////////////////////////////////////////////////////////////////////////// | ||
|
||
package main | ||
|
@@ -34,11 +34,11 @@ type rootT struct { | |
var root = &cli.Command{ | ||
Name: "wireframe", | ||
Desc: "wire framing\nVersion " + version + " built on " + date + | ||
"\nCopyright (C) 2019, Myself <[email protected]>", | ||
"\nCopyright (C) 2021, Myself <[email protected]>", | ||
Text: "Tool to showcase wire-framing command line app fast prototype", | ||
Global: true, | ||
Argv: func() interface{} { t := new(rootT); t.Self = t; return t }, | ||
Fn: wireframe, | ||
Fn: Wireframe, | ||
|
||
NumArg: cli.AtLeast(1), | ||
} | ||
|
@@ -64,7 +64,7 @@ var root = &cli.Command{ | |
// var ( | ||
// progname = "wireframe" | ||
// version = "0.1.0" | ||
// date = "2019-09-12" | ||
// date = "2021-02-14" | ||
|
||
// rootArgv *rootT | ||
// // Opts store all the configurable options | ||
|
@@ -76,9 +76,7 @@ var root = &cli.Command{ | |
|
||
// Function main | ||
// func main() { | ||
// cli.SetUsageStyle(cli.DenseNormalStyle) // left-right, for up-down, use ManualStyle | ||
// //NOTE: You can set any writer implements io.Writer | ||
// // default writer is os.Stdout | ||
// cli.SetUsageStyle(cli.DenseNormalStyle) | ||
// if err := cli.Root(root, | ||
// cli.Tree(putDef), | ||
// cli.Tree(getDef)).Run(os.Args[1:]); err != nil { | ||
|
@@ -92,7 +90,8 @@ var root = &cli.Command{ | |
//========================================================================== | ||
// Dumb root handler | ||
|
||
// func wireframe(ctx *cli.Context) error { | ||
// Wireframe - main dispatcher dumb handler | ||
// func Wireframe(ctx *cli.Context) error { | ||
// ctx.JSON(ctx.RootArgv()) | ||
// ctx.JSON(ctx.Argv()) | ||
// fmt.Println() | ||
|
@@ -119,8 +118,12 @@ var root = &cli.Command{ | |
// | ||
// DoPut implements the business logic of command `put` | ||
// func DoPut() error { | ||
// fmt.Fprintf(os.Stderr, "%s v%s. put - Upload into service\n", progname, version) | ||
// // fmt.Fprintf(os.Stderr, "Copyright (C) 2019, Myself <[email protected]>\n\n") | ||
// fmt.Fprintf(os.Stderr, "Upload into service\n") | ||
// // fmt.Fprintf(os.Stderr, "Copyright (C) 2021, Myself <[email protected]>\n\n") | ||
// // err := ... | ||
// // clis.WarnOn("Doing Put", err) | ||
// // or, | ||
// // clis.AbortOn("Doing Put", err) | ||
// return nil | ||
// } | ||
|
||
|
@@ -155,8 +158,12 @@ var putDef = &cli.Command{ | |
// | ||
// DoGet implements the business logic of command `get` | ||
// func DoGet() error { | ||
// fmt.Fprintf(os.Stderr, "%s v%s. get - Get from the service\n", progname, version) | ||
// // fmt.Fprintf(os.Stderr, "Copyright (C) 2019, Myself <[email protected]>\n\n") | ||
// fmt.Fprintf(os.Stderr, "Get from the service\n") | ||
// // fmt.Fprintf(os.Stderr, "Copyright (C) 2021, Myself <[email protected]>\n\n") | ||
// // err := ... | ||
// // clis.WarnOn("Doing Get", err) | ||
// // or, | ||
// // clis.AbortOn("Doing Get", err) | ||
// return nil | ||
// } | ||
|
||
|
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