From 5fe469e38cd4b87375cb6744d8436297417b75a4 Mon Sep 17 00:00:00 2001 From: Cornelius Toole Date: Sat, 15 Feb 2020 19:22:48 -0600 Subject: [PATCH] feat(file-ignore): add Strings option type - first step toward implementing file ignore feat(file-ignore): implement file ignore - add flags for providing a gitignore and/or list of files to ignore - construct a filter to be passed to a SerialFile feat(file-ignore): use go-ipfs-files fork; use renamed constructor feat(file-ignore): test case w. ignore rules; refactor parseArgs feat(file-ignore): ignore-rule opt is open-ended - make ignore-rules options accept a path to a file - add test case for ignore rules file feat(file-ignore): help-text for variardic opts - show StringsOption as variardic option in help-text - add test case for variardic option feat(file-ignore): rename rulesfile opt; fix typos feat(file-ignore): temp replace of go-ipfs-files - temporarily using go-ipfs-files fork until go-ipfs-files#26 is merged - trying to get ci/cd builds working - will revert before merging feat(file-ignore): refactor cli/parse.go#setOpts feat(file-ignore): cleanup parse.go; add test-case feat(file-ignore): update ignore option copytext feat(file-ignore): check opt against `optDef.Type` - revert exclusion of options with `Strings` type, so those option values are typechecked - add command test cases feat(file-ignore): add test-case w. hidden file feat(file-ignore): build against go-ipfs-files@latest feat(file-ignore): update go.mod/go.sum --- .gitignore | 1 + cli/helptext.go | 7 +- cli/helptext_test.go | 4 + cli/parse.go | 67 +++++++-- cli/parse_test.go | 159 +++++++++++++++++++- command_test.go | 5 + go.mod | 4 +- go.sum | 347 +++++++++++++++++++++++++++++++++++++++++++ option.go | 7 + opts.go | 4 + 10 files changed, 586 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index c0bf368..0dd366f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ cover.html examples/adder/local/local examples/adder/remote/client/client examples/adder/remote/server/server +coverage.out diff --git a/cli/helptext.go b/cli/helptext.go index 1c5480a..7b54d7f 100644 --- a/cli/helptext.go +++ b/cli/helptext.go @@ -301,7 +301,12 @@ func generateSynopsis(width int, cmd *cmds.Command, path string) string { } } } - appendText("[" + sopt + "]") + + if opt.Type() == cmds.Strings { + appendText("[" + sopt + "]...") + } else { + appendText("[" + sopt + "]") + } } if len(cmd.Arguments) > 0 { appendText("[--]") diff --git a/cli/helptext_test.go b/cli/helptext_test.go index c5f524c..7e13568 100644 --- a/cli/helptext_test.go +++ b/cli/helptext_test.go @@ -15,6 +15,7 @@ func TestSynopsisGenerator(t *testing.T) { }, Options: []cmds.Option{ cmds.StringOption("opt", "o", "Option"), + cmds.StringsOption("var-opt", "Variadic Option"), }, Helptext: cmds.HelpText{ SynopsisOptionsValues: map[string]string{ @@ -31,6 +32,9 @@ func TestSynopsisGenerator(t *testing.T) { if !strings.Contains(syn, "[--opt=