Commit Graph

194 Commits

Author SHA1 Message Date
meatballhat 5e5df7c325 Merge commit '63cb372' into v3-porting 2022-11-07 08:34:48 -05:00
meatballhat 2a68aa0894 Merge commit '8ea10b8' into v3-porting 2022-11-07 08:29:57 -05:00
GuangyuFan 63cb372cce Feature: (issue_1451) customized slice flag separator (#1546)
* feat: customized slice flag separator

* feat: modify go doc

* feat: update unit test
2022-10-27 17:32:00 +08:00
Naveen Gogineni 96bff3c5e1 Remove flag_windows and use runtime 2022-10-19 09:44:21 -04:00
Naveen Gogineni da8868ffd9 Fix:(issue_1288). Add windows specific env format 2022-10-18 19:53:02 -04:00
meatballhat 96216756c2 Remove duplicate DocGenerationFlag interface
introduced via merge
2022-10-09 12:41:30 -04:00
meatballhat 64facdbe2f Merge remote-tracking branch 'origin/v3-dev-main' into v3-porting 2022-10-09 12:40:44 -04:00
Naveen Gogineni 924ebdaab2 Fix:(issue_1500). Fix slice flag value duplication issue 2022-10-09 10:09:36 -04:00
Felix Lange 82ea9f70c0 Call FlagStringer in String() method of slice flags
The default help template relies on the String() method of Flag
to render the flag. For most flag types, String() indirects through
FlagStringer, so that is the best place to customize flag rendering.

FlagStringer was not called for slice flags because their help output
differs from other flags in two ways: there can be multiple default
values, and the flag name is shown two times to indicate that the flag
can be specified multiple times.

To make multiple values work in the FlagStringer, I simply changed
GetValue() to return all values.

Showing the flag more than once is achieved through a new interface,
DocGenerationSliceFlag, which the FlagStringer uses to decide whether
the flag is a slice flag type.
2022-10-09 09:50:12 -04:00
Naveen Gogineni 1a31a6e2fc Revert "Remove all flag interfaces"
This reverts commit 268cb973f8.
2022-10-08 09:47:46 -05:00
Wendell Sun e2e14ec6ef feat: flag action 2022-10-03 08:28:44 -04:00
Naveen Gogineni 0764ca2295 Rebase 2022-10-03 07:47:10 -04:00
Naveen Gogineni fdcbf28476 Merge changes from main 2022-10-03 07:41:53 -04:00
Naveen Gogineni a509290e75 Add countable interface 2022-10-02 21:16:15 -04:00
Naveen Gogineni 45a1375078 Changes from code review 2022-10-01 19:46:52 -04:00
Naveen Gogineni bc99b5865c issue_62: Make slice options more posix like 2022-10-01 19:46:20 -04:00
Felix Lange 72cbb3db6a Call FlagStringer in String() method of slice flags
The default help template relies on the String() method of Flag
to render the flag. For most flag types, String() indirects through
FlagStringer, so that is the best place to customize flag rendering.

FlagStringer was not called for slice flags because their help output
differs from other flags in two ways: there can be multiple default
values, and the flag name is shown two times to indicate that the flag
can be specified multiple times.

To make multiple values work in the FlagStringer, I simply changed
GetValue() to return all values.

Showing the flag more than once is achieved through a new interface,
DocGenerationSliceFlag, which the FlagStringer uses to decide whether
the flag is a slice flag type.
2022-09-30 15:01:22 +02:00
Wendell Sun 619958c3d2 Add ActionableFlag interface instead of modifying Flag interface directly 2022-09-16 00:07:14 +09:00
Wendell Sun 14366f7030 feat: flag action 2022-09-16 00:07:12 +09:00
Naveen Gogineni dbdf119742 Add countable interface 2022-09-06 08:48:56 -04:00
Naveen Gogineni 069c6bfe4a Run gofmt 2022-09-05 08:12:38 -04:00
Naveen Gogineni 268cb973f8 Remove all flag interfaces 2022-09-04 22:51:05 -04:00
Naveen Gogineni ab68d8a69d Cleanup: Collapse flag interfaces 2022-09-04 22:18:41 -04:00
Naveen Gogineni af3b50c2bb Changes from code review 2022-08-14 20:36:17 -04:00
Naveen Gogineni b80ff3d32f issue_62: Make slice options more posix like 2022-08-14 20:36:17 -04:00
meatballhat 4bca72cea1 Merge remote-tracking branch 'origin/main' into michaeljs1990-add-flag-category-support 2022-05-22 11:06:38 -04:00
meatballhat 04f5ff0315 Merge branch 'main' into mostynb-report_source_of_parse_errors 2022-05-07 08:57:48 -04:00
meatballhat ae97940956 Merge remote-tracking branch 'origin/main' into michaeljs1990-add-flag-category-support 2022-05-07 08:45:57 -04:00
meatballhat ed0033984b Generate flag types (again?)
Closes #1381
2022-05-01 23:02:05 -04:00
meatballhat e7db6af492 Merge remote-tracking branch 'origin/main' into mostynb-report_source_of_parse_errors 2022-04-30 14:19:06 -04:00
meatballhat a583a102fd Merge remote-tracking branch 'origin/main' into michaeljs1990-add-flag-category-support 2022-04-28 20:29:09 -04:00
meatballhat 6538e95d65 Merge branch 'ally_fix_multi_val' of ssh://github.com/vipally/cli into vipally-ally_fix_multi_val 2022-04-25 22:45:39 -04:00
Kacper Bąk 4c7b46cb24 fix: clean code 2022-04-25 19:11:11 +02:00
meatballhat 75e4ee69e9 Porting remainder of #796 2022-04-22 15:01:40 -04:00
meatballhat 44958693a1 Merge branch 'add-flag-category-support' of ssh://github.com/michaeljs1990/cli into michaeljs1990-add-flag-category-support 2022-04-22 13:56:03 -04:00
meatballhat d83bb8d85e Merge branch 'main' into remove_reflect 2022-04-21 20:22:26 -04:00
meatballhat 826b3edd3f Merge branch 'report_source_of_parse_errors' of ssh://github.com/mostynb/cli into mostynb-report_source_of_parse_errors 2022-04-19 19:41:57 -04:00
Kir Kolyshkin 3df9a3cd86 Don't call open("") (#1336)
strings.Split(s, sep) returns a slice of a single element containing s
if sep is not found in s. This is true even if s is empty.

As a result, every call to flagFromEnvOrFile results in an attempt to
open a file with empty name. This is seen from strace as

[pid 3287620] openat(AT_FDCWD, "", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 3287620] openat(AT_FDCWD, "", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
...

To fix, check if the string is empty before calling ReadFile.

This also fixes cases where filePath is non-empty but has extra commas.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-02-15 08:28:44 -05:00
Naveen Gogineni 50c71ed517 Remove reflect calls for doc generation 2021-04-28 20:50:29 -04:00
Robert Liebowitz e79ceb69ff Merge pull request #1258 from dearchap/visible_interface
Fix(issue #631). Remove reflect calls for Hidden field
2021-04-24 13:10:52 -04:00
Naveen Gogineni 07e1fdf17d Cleanup context.go 2021-04-05 07:57:41 -04:00
Naveen Gogineni df595c0d85 Fix(issue #631). Remove reflect calls for Hidden field 2021-03-25 20:45:30 -04:00
Ally Dale ef9430e77e fix #1238: accept multi-value input on sclice flags 2021-02-08 20:10:28 +08:00
Madhur batra ea14b62ecc Issue #1066: Display (accepts multiple inputs) for SliceFlags in the
help description.
2020-12-01 14:14:15 +05:00
Mostyn Bramley-Moore cdc1f6e07c fixup! Report the source of a value when we cannot parse it
move bool to the end of the return arguments

remove "from " prefix in the source/fromWhere description

remove TODO notes from functions that don't currently perform error checking
2020-11-07 14:05:39 +01:00
Mostyn Bramley-Moore 500d6b04e6 Report the source of a value when we cannot parse it
If you allow a flag to be set from environment variables or files and
a parse error occurs from one of them, it is very useful for the error
message to mention where the value came from.

Without this, it can be difficult to notice an error caused by an
unexpected environment variable being set.

Implements #1167.
2020-11-03 23:57:00 +01:00
Robert Liebowitz d648edd48d Merge pull request #1083 from AkihiroSuda/hide-help-command
Add HideHelpCommand
2020-03-06 07:46:02 -05:00
Akihiro Suda 75e7c526bd Add HideHelpCommand
While `HideHelp` hides both `help` command and `--help` flag, `HideHelpCommand`
only hides `help` command and leave `--help` flag as-is.

The behavior of `HideHelp` is untouched in this commit.

Fix #523
Replace #636

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-03-06 16:17:24 +09:00
Sascha Grunert 7742363500 Refactor '(default: …)' flag string into utility function
The usage of the `(default: …)` strings are a bit error prone so we now
refactor them into a dedicated helper function.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-03-02 13:05:45 +01:00
Dmitry Kutakov 8c28ae347a refactor flag names - make it more explicitly
avoid the using 'reflect' package while getting flag names
2019-12-29 08:58:12 +01:00