Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
fuchsia.googlesource.com-third_party-github.com-google-subcommands
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fuchsia-mirror
fuchsia.googlesource.com-third_party-github.com-google-subcommands
Commits
1de6a896
Commit
1de6a896
authored
9 years ago
by
Andrew Jackura
Browse files
Options
Downloads
Patches
Plain Diff
Fix formating
parent
5ef2aa78
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+16
-16
16 additions, 16 deletions
README.md
subcommands.go
+1
-1
1 addition, 1 deletion
subcommands.go
with
17 additions
and
17 deletions
README.md
+
16
−
16
View file @
1de6a896
...
...
@@ -11,40 +11,40 @@ Set up a 'print' subcommand:
```
import (
"flag"
"fmt"
"os"
"strings"
"flag"
"fmt"
"os"
"strings"
"github.com/google/subcommands"
"golang.org/x/net/context"
"github.com/google/subcommands"
"golang.org/x/net/context"
)
type printCmd struct {
capitalize bool
capitalize bool
}
func (*printCmd) Name() string { return "print" }
func (*printCmd) Synopsis() string { return "Print args to stdout." }
func (*printCmd) Usage() string {
return `print [-capitalize] <some text>:
return `print [-capitalize] <some text>:
Print args to stdout.
`
}
func (p *printCmd) SetFlags(f *flag.FlagSet) {
f.BoolVar(&p.capitalize, "capitalize", false, "capitalize output")
f.BoolVar(&p.capitalize, "capitalize", false, "capitalize output")
}
func (p *printCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
for _, arg := range f.Args() {
if p.capitalize {
arg = strings.ToUpper(arg)
}
fmt.Printf("%s ", arg)
}
if p.capitalize {
arg = strings.ToUpper(arg)
}
fmt.Printf("%s ", arg)
}
fmt.Println()
return subcommands.ExitSuccess
return subcommands.ExitSuccess
}
```
...
...
@@ -59,7 +59,7 @@ func main() {
subcommands.Register(&print{}, "")
ctx := context.Background()
os.Exit(int(subcommands.Execute(ctx)))
os.Exit(int(subcommands.Execute(ctx)))
}
```
This diff is collapsed.
Click to expand it.
subcommands.go
+
1
−
1
View file @
1de6a896
...
...
@@ -26,7 +26,7 @@ import (
"sort"
"flag"
"golang.org/x/net/context"
"golang.org/x/net/context"
)
// A Command represents a single command.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment