-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1553 from dearchap/altsrc_generation
Chore: Add altsrc flag definition generation
- Loading branch information
Showing
5 changed files
with
156 additions
and
86 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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# NOTE: this file is used by the tool defined in | ||
# ./cmd/urfave-cli-genflags/main.go which uses the | ||
# `Spec` type that maps to this file structure. | ||
flag_types: | ||
Bool: | ||
Duration: | ||
Float64: | ||
Generic: | ||
Int64: | ||
Int: | ||
IntSlice: | ||
Int64Slice: | ||
Float64Slice: | ||
String: | ||
Path: | ||
StringSlice: | ||
Uint64: | ||
Uint: |
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
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,34 @@ | ||
// WARNING: this file is generated. DO NOT EDIT | ||
|
||
package {{.PackageName}} | ||
|
||
import ( | ||
"flag" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
{{range .SortedFlagTypes}} | ||
// {{.TypeName}} is the flag type that wraps cli.{{.TypeName}} to allow | ||
// for other values to be specified | ||
type {{.TypeName}} struct { | ||
*cli.{{.TypeName}} | ||
set *flag.FlagSet | ||
} | ||
|
||
// New{{.TypeName}} creates a new {{.TypeName}} | ||
func New{{.TypeName}}(fl *cli.{{.TypeName}}) *{{.TypeName}} { | ||
return &{{.TypeName}}{{"{"}}{{.TypeName}}: fl, set: nil} | ||
} | ||
|
||
// Apply saves the flagSet for later usage calls, then calls | ||
// the wrapped {{.TypeName}}.Apply | ||
func (f *{{.TypeName}}) Apply(set *flag.FlagSet) error { | ||
f.set = set | ||
return f.{{.TypeName}}.Apply(set) | ||
} | ||
{{end}}{{/* /range .SortedFlagTypes */}} | ||
|
||
// vim{{/* 👻 */}}:ro | ||
{{/* | ||
vim:filetype=gotexttmpl | ||
*/}} |
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