Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Porting main to v3-dev-main circa 2022-11-06 #1569

Merged
merged 211 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
211 commits
Select commit Hold shift + click to select a range
c0f57e0
Merge remote-tracking branch 'origin/main' into merging-main-to-v3-de…
meatballhat Jul 16, 2022
cb7532a
Merge pull request #1437 from urfave/merging-main-to-v3-dev-main
meatballhat Jul 16, 2022
887d31f
Target minimum go 1.18 in v3-dev-main
meatballhat Jul 16, 2022
3216104
Merge pull request #1438 from urfave/v3-target-1.18-min
dearchap Aug 13, 2022
ab68d8a
Cleanup: Collapse flag interfaces
dearchap Sep 5, 2022
268cb97
Remove all flag interfaces
dearchap Sep 5, 2022
069c6bf
Run gofmt
dearchap Sep 5, 2022
7e80d20
Update godoc
dearchap Sep 5, 2022
0a88df4
Merge pull request #1471 from dearchap/collapse_flag_interface
dearchap Sep 5, 2022
93a3190
Bump declared module and internal usage to `/v3/`
meatballhat Sep 12, 2022
22ff9a3
Soft revert go.mod version bump
meatballhat Sep 29, 2022
40d886b
Add stub for v3 docs + point gfmrun there instead
meatballhat Sep 30, 2022
dd9cd61
Fix for TimestampFlag.GetValue to return empty string without value
hmiyado Jul 18, 2022
67f592a
Fix HideHelp
Jul 29, 2022
02eb392
Fix After not run
Jul 28, 2022
bc99b58
issue_62: Make slice options more posix like
dearchap Aug 14, 2022
45a1375
Changes from code review
dearchap Aug 15, 2022
2ca9143
Move genflags tool to cmd/ and pin to previous release
meatballhat Aug 14, 2022
d8de3b5
Tidy up top-level go.mod
meatballhat Aug 14, 2022
a5313eb
Add missing go.sum entries for go 1.16.x
meatballhat Aug 14, 2022
67b3de0
Turn off docs publishing from v3 series
meatballhat Oct 2, 2022
cbc7f1a
Use goimports as formatting standard
meatballhat Aug 14, 2022
76bb9f1
Shift supported go versions
meatballhat Aug 14, 2022
1ae70fc
split v1 docs into individual pages
hay-kot Aug 14, 2022
edaf885
breakup v2 documentation
hay-kot Aug 14, 2022
18f8e6d
update sidebar configuration
hay-kot Aug 14, 2022
7cfafe8
add tags plugin
hay-kot Aug 15, 2022
8036eac
add tags and boost for pages
hay-kot Aug 15, 2022
d217a5a
wip: add --walk flag to gfrun to accept directory
hay-kot Aug 15, 2022
87f003f
pass in correct root
hay-kot Aug 15, 2022
2b1a8ca
rename filename to dirPath
hay-kot Aug 15, 2022
42d8058
Fix:(issue_1094) Dont execute Before/After handlers during shell comp…
dearchap Aug 18, 2022
42eb492
Rename function
dearchap Aug 18, 2022
78dac9c
Fix:(issue_1455) Allow bool flags from input altsrc
dearchap Aug 16, 2022
3c6588c
Remove debug println
dearchap Aug 23, 2022
f515798
Revert godoc changes
dearchap Aug 23, 2022
382386a
Add configurable Base to int, uint and uint64 flags
ccremer Aug 25, 2022
9de6fa4
fix: allow required flag with one character
Gerrard-YNWA Aug 14, 2022
9092325
fix: update test case
Gerrard-YNWA Aug 14, 2022
e0db267
adding in boolean alias support
james-prysm Aug 11, 2022
50bbb4a
adding string alias and test
james-prysm Aug 25, 2022
5a5789a
adding int alias and test
james-prysm Aug 25, 2022
c512a28
add support for duration flag
james-prysm Aug 25, 2022
126d238
adding float flag alias support
james-prysm Aug 25, 2022
9630e10
adding alias support to remaining flags and fixing tests
james-prysm Aug 25, 2022
9a33ae8
fixing test
james-prysm Aug 25, 2022
d520bfc
Modify nesting flag apply
Aug 30, 2022
445734d
Update v2 dead link
abousselmi Aug 30, 2022
b539ee7
Fix:(issue_1293) Wrap usage text for commands
dearchap Aug 20, 2022
d89bc4a
Change way to calculate offset
dearchap Aug 24, 2022
96e41a6
Make test case more robust
dearchap Aug 25, 2022
e48d377
Remove add function
dearchap Aug 27, 2022
321d493
Add comment
dearchap Aug 30, 2022
6331815
Add App.UnknownFlagHandler
icholy Aug 2, 2022
e19a34c
Rename App.UnknownFlagHandler to App.InvalidFlagAccessHandler
icholy Aug 8, 2022
4bce542
Traverse parent contexts
icholy Aug 15, 2022
a529996
Merge pull request #1511 from urfave/v3-docs-off
meatballhat Oct 3, 2022
bd44c95
Merge pull request #1494 from urfave/v3-mod-bump
meatballhat Oct 3, 2022
68cd3e8
Fix:(issue_1272) Generic flag not set from env
dearchap Aug 19, 2022
d34a232
Merge remote-tracking branch 'origin/v3-dev-main' into v3-porting
meatballhat Oct 3, 2022
1446649
Use cli/v2 in genflags tool (for now?)
meatballhat Oct 3, 2022
e57f53b
Update cli.yml
sashashura Sep 2, 2022
8609031
Update version of codecov action
meatballhat Sep 5, 2022
31edfd6
Explicitly pass CODECOV_TOKEN
meatballhat Sep 5, 2022
eea567a
Add a few notes to release docs
meatballhat Sep 5, 2022
03487fc
Add count option for bool flags
dearchap Mar 23, 2021
2941bc8
Merge changes onto latest main
dearchap Aug 13, 2022
c4251de
Remove go changes
dearchap Aug 13, 2022
2b0db3b
Update for build
dearchap Aug 16, 2022
c0a2866
Merge main and run tidy
dearchap Aug 28, 2022
2f082d6
Rebase main
dearchap Sep 5, 2022
2f66431
Add to docs
dearchap Sep 5, 2022
b694a25
Update docs
dearchap Sep 5, 2022
cbd62ef
Update godocs
dearchap Sep 5, 2022
3adf8fa
Add args
dearchap Sep 5, 2022
fa3bbf9
Update docs/v2/examples/flags.md
dearchap Sep 5, 2022
c0a8506
Add context.Count
dearchap Sep 5, 2022
6b0a3e8
Add parametrize tests
dearchap Sep 5, 2022
a509290
Add countable interface
dearchap Sep 5, 2022
d58b3c7
Remove keystroke errors
dearchap Sep 6, 2022
fdcbf28
Merge changes from main
dearchap Aug 13, 2022
0764ca2
Rebase
dearchap Aug 15, 2022
7097d0e
Fix tests per latest main
dearchap Aug 15, 2022
7405a90
Fix formatting
dearchap Aug 31, 2022
9bcffd0
Merge from main
dearchap Aug 31, 2022
2a5960c
Add coverage threshold
dearchap Sep 6, 2022
5b96605
Add additional test to fix codecov
dearchap Sep 10, 2022
9c5b385
Add additional test to fix codecov
dearchap Sep 10, 2022
0658d61
Set codecov status thresholds to 5%
meatballhat Sep 10, 2022
e13c16b
Fix: dont generate pointer for dest for Generic flag
dearchap Sep 10, 2022
8e3fa06
Fix: Help name consistency among app/commands and subcommands
dearchap Sep 11, 2022
8cc0a9c
Move more functionality into internal/build/build.go
meatballhat Sep 11, 2022
d9d960a
Run make target after the Makefile is available
meatballhat Sep 11, 2022
2bec081
Use windows compatible path append
meatballhat Sep 11, 2022
0593812
Only run `make v2diff` on go `1.19.x` + `ubuntu-latest`
meatballhat Sep 11, 2022
d6c9f6a
Replace a few more custom make targets
meatballhat Sep 11, 2022
9ed5a09
Use correct env var for global flags
meatballhat Sep 11, 2022
1c3ebfa
Accept the `MKDOCS_REMOTE_GITHUB_TOKEN` var as intended
meatballhat Sep 12, 2022
d2acd0e
Fix:(issue_1197) Set destination field from altsrc for slice flags
dearchap Sep 12, 2022
e9e87f6
Add unit tests
dearchap Sep 12, 2022
a2c3729
fix: Context.Set no such flag
Sep 20, 2022
e2e14ec
feat: flag action
xwjdsh Feb 15, 2022
f9ceca5
Add more tests about flag-level action
xwjdsh Apr 30, 2022
d213683
Rebase main, update flag-spec.yaml to add Action field
xwjdsh May 22, 2022
1e30f50
make v2approve
xwjdsh Sep 15, 2022
126297a
Add more test cases
xwjdsh Sep 17, 2022
4c637d8
Fix:(issue_557) Change app help name
dearchap Aug 21, 2022
57ff098
Fix:(issue_557) Make help output consistent between different invocat…
dearchap Sep 21, 2022
c2ecb44
Remove un-needed func
dearchap Sep 21, 2022
8ef92d2
Remove un-needed func
dearchap Sep 21, 2022
5db9db6
Remove nonexistent phony targets
meatballhat Sep 29, 2022
f8faf77
Post-porting fixes for v3
meatballhat Oct 3, 2022
a851a77
Point docs tests at v3
meatballhat Oct 3, 2022
9166808
Merge pull request #1510 from urfave/v3-porting
dearchap Oct 6, 2022
1a31a6e
Revert "Remove all flag interfaces"
dearchap Oct 8, 2022
cf41aab
Revert changes
dearchap Oct 8, 2022
662deaa
Run v2approve
dearchap Oct 8, 2022
a6f5ca6
wrap: Avoid trailing whitespace for empty lines
abitrolly Oct 3, 2022
d3bb381
Fix test for removed trailing whitespace
abitrolly Oct 3, 2022
05fb755
wrap: Simplify loop logic
abitrolly Oct 4, 2022
e14dca7
Run `go fmt`
abitrolly Oct 4, 2022
4959a9f
Refactor `wrap()` and add test for empty line
abitrolly Oct 4, 2022
82ea9f7
Call FlagStringer in String() method of slice flags
fjl Sep 30, 2022
65c98c8
Ensure "generate" step runs in CI prior to diff check
meatballhat Sep 29, 2022
c5057d1
Only run generate on go 1.19
meatballhat Sep 30, 2022
01bdec7
Set destination in GenericFlag apply function
nkuba Jul 26, 2022
b82e628
Add unit test for GenericFlag Destination parsing
nkuba Jul 26, 2022
13860a7
Fix:(issue_1505) Fix flag alignment in help
dearchap Sep 30, 2022
ae8c511
Fix command help subcommand
dearchap Sep 30, 2022
c86805d
Add test case
dearchap Sep 30, 2022
dccd762
Componentize template
dearchap Sep 30, 2022
a4b7759
Update template.go
dearchap Oct 5, 2022
9a94619
Add test coverage for Command.VisibleCommands()
dearchap Oct 5, 2022
ea28930
Remove extra 3 spaces in last line
dearchap Oct 5, 2022
924ebda
Fix:(issue_1500). Fix slice flag value duplication issue
dearchap Sep 29, 2022
fcb0bce
Fix failed test
dearchap Oct 5, 2022
83ea416
Merge pull request #1517 from dearchap/revert_remove_all_flag_interfaces
dearchap Oct 9, 2022
64facdb
Merge remote-tracking branch 'origin/v3-dev-main' into v3-porting
meatballhat Oct 9, 2022
9621675
Remove duplicate DocGenerationFlag interface
meatballhat Oct 9, 2022
6404f1d
Backfill drop of generated GetDefaultText method
meatballhat Oct 10, 2022
b458207
Build and run `urfave-cli-genflags` via its `Makefile`
meatballhat Oct 9, 2022
75aabac
Use existing goimports installation if available
meatballhat Oct 10, 2022
85ff0c5
Un-regress from v3 porting losses
meatballhat Oct 13, 2022
25897ce
Merge pull request #1525 from urfave/v3-porting
meatballhat Oct 16, 2022
9aa0dd7
Merge commit 'c8147a4' into v3-porting
meatballhat Nov 7, 2022
874d06d
Merge commit 'e3ee4fb' into v3-porting
meatballhat Nov 7, 2022
16c0635
Merge commit 'ade5edb' into v3-porting
meatballhat Nov 7, 2022
fd3354f
Merge commit 'af3b50c' into v3-porting
meatballhat Nov 7, 2022
3c66d6d
Merge commit '6ff3e8e' into v3-porting
meatballhat Nov 7, 2022
63b730e
Merge commit '234972e' into v3-porting
meatballhat Nov 7, 2022
ba1c00e
Merge commit '3a1b6de' into v3-porting
meatballhat Nov 7, 2022
f68da12
Merge commit '87dedb6' into v3-porting
meatballhat Nov 7, 2022
140c96c
Merge commit 'dac1c40' into v3-porting
meatballhat Nov 7, 2022
8c34fbc
Merge commit 'c6616c3' into v3-porting
meatballhat Nov 7, 2022
504ec56
Merge commit '7357e10' into v3-porting
meatballhat Nov 7, 2022
4e3a327
Merge commit '7b28ca5' into v3-porting
meatballhat Nov 7, 2022
ff6f4b4
Merge commit 'b4df361' into v3-porting
meatballhat Nov 7, 2022
38546ca
Merge commit 'f394c37' into v3-porting
meatballhat Nov 7, 2022
ade08d5
Merge commit '77a5fef' into v3-porting
meatballhat Nov 7, 2022
a9bf2e7
Merge commit '8b23e7b' into v3-porting
meatballhat Nov 7, 2022
c19cd38
Merge commit 'b98c059' into v3-porting
meatballhat Nov 7, 2022
5dcfcce
Merge commit 'f664246' into v3-porting
meatballhat Nov 7, 2022
dc0ad27
Merge commit '514a114' into v3-porting
meatballhat Nov 7, 2022
037f2e0
Merge commit '254c38e' into v3-porting
meatballhat Nov 7, 2022
a210601
Merge commit 'ca9df40' into v3-porting
meatballhat Nov 7, 2022
86c8e26
Merge commit 'f451dea' into v3-porting
meatballhat Nov 7, 2022
5a4235b
Merge commit '31c5137' into v3-porting
meatballhat Nov 7, 2022
e903170
Merge commit 'b1b1b27' into v3-porting
meatballhat Nov 7, 2022
c6217c3
Merge commit '6ccecf2' into v3-porting
meatballhat Nov 7, 2022
edd0171
Merge commit 'd62ac9c' into v3-porting
meatballhat Nov 7, 2022
94aa8fa
Merge commit '6124f3a' into v3-porting
meatballhat Nov 7, 2022
b74b095
Merge commit '8dba5c3' into v3-porting
meatballhat Nov 7, 2022
2472253
Merge commit '375e5df' into v3-porting
meatballhat Nov 7, 2022
9916a64
Merge commit '69f4122' into v3-porting
meatballhat Nov 7, 2022
3c86c6d
Merge commit '9120e06' into v3-porting
meatballhat Nov 7, 2022
66586eb
Merge commit '880a802' into v3-porting
meatballhat Nov 7, 2022
6ff66e0
Merge commit '9f465af' into v3-porting
meatballhat Nov 7, 2022
0a0546f
Merge commit 'a81e201' into v3-porting
meatballhat Nov 7, 2022
0de6633
Merge commit 'de83493' into v3-porting
meatballhat Nov 7, 2022
cc9361c
Merge commit '6491dde' into v3-porting
meatballhat Nov 7, 2022
f28f38d
Merge commit '8335f54' into v3-porting
meatballhat Nov 7, 2022
110e97b
Merge commit 'fe6f62b' into v3-porting
meatballhat Nov 7, 2022
1ed843e
Merge commit '2da0324' into v3-porting
meatballhat Nov 7, 2022
0f45f18
Merge commit 'a27294d' into v3-porting
meatballhat Nov 7, 2022
af8fe35
Merge commit '3c5c3a4' into v3-porting
meatballhat Nov 7, 2022
0420682
Merge commit 'b68db8d' into v3-porting
meatballhat Nov 7, 2022
d23a7e4
Merge commit '8f469ab' into v3-porting
meatballhat Nov 7, 2022
fb50ebc
Merge commit '2a4809f' into v3-porting
meatballhat Nov 7, 2022
a1f9917
Merge commit 'f64acc4' into v3-porting
meatballhat Nov 7, 2022
f94fffd
Merge commit 'f37b9d9' into v3-porting
meatballhat Nov 7, 2022
8bcc404
Merge commit '89e331f' into v3-porting
meatballhat Nov 7, 2022
581cfd1
Merge commit '0d0d329' into v3-porting
meatballhat Nov 7, 2022
8530ea2
Merge commit 'adcd0c9' into v3-porting
meatballhat Nov 7, 2022
4ac1d33
Merge commit '39b1245' into v3-porting
meatballhat Nov 7, 2022
b0e8160
Merge commit '5ac0710' into v3-porting
meatballhat Nov 7, 2022
1564c86
Merge commit 'cf49ddb' into v3-porting
meatballhat Nov 7, 2022
1643a78
Merge commit 'd1ac284' into v3-porting
meatballhat Nov 7, 2022
2a68aa0
Merge commit '8ea10b8' into v3-porting
meatballhat Nov 7, 2022
d3a4181
Merge commit '7563894' into v3-porting
meatballhat Nov 7, 2022
da23da7
Merge commit '82bdf5f' into v3-porting
meatballhat Nov 7, 2022
5e5df7c
Merge commit '63cb372' into v3-porting
meatballhat Nov 7, 2022
84af977
Merge commit 'c344b46' into v3-porting
meatballhat Nov 7, 2022
494ff26
Merge commit 'ae8d932' into v3-porting
meatballhat Nov 7, 2022
d80f366
Merge commit 'c3fccc0' into v3-porting
meatballhat Nov 7, 2022
c6318ce
Merge commit 'd0aeb4d' into v3-porting
meatballhat Nov 7, 2022
3d52a48
Merge commit 'e194a18' into v3-porting
meatballhat Nov 7, 2022
8b891ea
Merge commit '190e5b6' into v3-porting
meatballhat Nov 7, 2022
75f2d1a
Merge commit '46043dd' into v3-porting
meatballhat Nov 7, 2022
d294a88
Adjust expectations around categorized flags
meatballhat Nov 8, 2022
5e86a2c
Leave imports to goimports
meatballhat Nov 8, 2022
a5ec63b
More porting fixes and un-lost changes
meatballhat Nov 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions .github/workflows/cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@ on:
push:
branches:
- main
- v3-dev-main
tags:
- v2.*
- v3.*
pull_request:
branches:
- main
- v3-dev-main
permissions:
contents: read
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
go: [1.17.x, 1.18.x, 1.19.x]
go: [1.18.x, 1.19.x]
name: ${{ matrix.os }} @ Go ${{ matrix.go }}
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -43,13 +46,17 @@ jobs:
- if: matrix.go == '1.19.x' && matrix.os == 'ubuntu-latest'
run: make generate
- run: make diffcheck
- if: matrix.go == '1.19.x' && matrix.os == 'ubuntu-latest'
# TODO: switch once v3 is released {{
# - if: matrix.go == '1.19.x' && matrix.os == 'ubuntu-latest'
- if: 'false'
run: make v2diff
# }}
- if: success() && matrix.go == '1.19.x' && matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true

test-docs:
name: test-docs
runs-on: ubuntu-latest
Expand All @@ -66,12 +73,15 @@ jobs:
- run: make ensure-gfmrun
- run: make gfmrun
env:
FLAGS: --walk docs/v2/
FLAGS: --walk docs/v3/
- run: make diffcheck
publish:
permissions:
contents: write
if: startswith(github.ref, 'refs/tags/')
# TODO: switch once v3 is released {{
# if: startswith(github.ref, 'refs/tags/')
if: 'false'
# }}
name: publish
needs: [test-docs]
runs-on: ubuntu-latest
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
.envrc
.idea
/.local/
/cmd/urfave-cli-genflags/urfave-cli-genflags
/site/
coverage.txt
internal/*/built-example
vendor
/cmd/urfave-cli-genflags/urfave-cli-genflags
*.exe
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
GO_RUN_BUILD := go run internal/build/build.go

.PHONY: all
all: generate vet test check-binary-size gfmrun yamlfmt v2diff
all: generate vet test check-binary-size gfmrun yamlfmt

# NOTE: this is a special catch-all rule to run any of the commands
# defined in internal/build/build.go with optional arguments passed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# cli

[![GoDoc](https://godoc.org/github.com/urfave/cli?status.svg)](https://pkg.go.dev/github.com/urfave/cli/v2)
[![GoDoc](https://godoc.org/github.com/urfave/cli?status.svg)](https://pkg.go.dev/github.com/urfave/cli/v3)
[![codebeat](https://codebeat.co/badges/0a8f30aa-f975-404b-b878-5fab3ae1cc5f)](https://codebeat.co/projects/github-com-urfave-cli)
[![Go Report Card](https://goreportcard.com/badge/urfave/cli)](https://goreportcard.com/report/urfave/cli)
[![codecov](https://codecov.io/gh/urfave/cli/branch/main/graph/badge.svg)](https://codecov.io/gh/urfave/cli)
Expand Down
2 changes: 1 addition & 1 deletion altsrc/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strconv"
"syscall"

"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"
)

// FlagInputSourceExtension is an extension interface of cli.Flag that
Expand Down
2 changes: 1 addition & 1 deletion altsrc/flag_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package altsrc
import (
"flag"

"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"
)

// BoolFlag is the flag type that wraps cli.BoolFlag to allow
Expand Down
2 changes: 1 addition & 1 deletion altsrc/flag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"testing"
"time"

"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"
)

type testApplyInputSource struct {
Expand Down
2 changes: 1 addition & 1 deletion altsrc/input_source_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package altsrc
import (
"time"

"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"
)

// InputSourceContext is an interface used to allow
Expand Down
2 changes: 1 addition & 1 deletion altsrc/json_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"
"testing"

"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion altsrc/json_source_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
"time"

"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"
)

// NewJSONSourceFromFlagFunc returns a func that takes a cli.Context
Expand Down
2 changes: 1 addition & 1 deletion altsrc/map_input_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"time"

"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"
)

// MapInputSource implements InputSourceContext to return
Expand Down
2 changes: 1 addition & 1 deletion altsrc/toml_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"
"testing"

"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"
)

func TestCommandTomFileTest(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion altsrc/toml_file_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"reflect"

"github.com/BurntSushi/toml"
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"
)

type tomlMap struct {
Expand Down
2 changes: 1 addition & 1 deletion altsrc/yaml_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"
"testing"

"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"
)

func TestCommandYamlFileTest(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion altsrc/yaml_file_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"runtime"
"strings"

"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"

"gopkg.in/yaml.v3"
)
Expand Down
4 changes: 2 additions & 2 deletions altsrc/yaml_file_loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"os"
"time"

"github.com/urfave/cli/v2"
"github.com/urfave/cli/v2/altsrc"
"github.com/urfave/cli/v3"
"github.com/urfave/cli/v3/altsrc"
)

func ExampleApp_Run_yamlFileLoaderDuration() {
Expand Down
20 changes: 20 additions & 0 deletions app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2486,6 +2486,26 @@ func (c *customBoolFlag) IsSet() bool {
return false
}

func (c *customBoolFlag) IsRequired() bool {
return false
}

func (c *customBoolFlag) IsVisible() bool {
return false
}

func (c *customBoolFlag) GetCategory() string {
return ""
}

func (c *customBoolFlag) GetEnvVars() []string {
return nil
}

func (c *customBoolFlag) GetDefaultText() string {
return ""
}

func TestCustomFlagsUnused(t *testing.T) {
app := &App{
Flags: []Flag{&customBoolFlag{"custom"}},
Expand Down
29 changes: 23 additions & 6 deletions cmd/urfave-cli-genflags/generated.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,38 @@ func (f *{{.TypeName}}) Names() []string {
return {{$.UrfaveCLINamespace}}FlagNames(f.Name, f.Aliases)
}

{{end}}{{/* /if .GenerateFlagInterface */}}

{{if .GenerateRequiredFlagInterface}}
// IsRequired returns whether or not the flag is required
func (f *{{.TypeName}}) IsRequired() bool {
return f.Required
}
{{end}}{{/* /if .GenerateRequiredFlagInterface */}}

{{if .GenerateVisibleFlagInterface}}
// IsVisible returns true if the flag is not hidden, otherwise false
func (f *{{.TypeName}}) IsVisible() bool {
return !f.Hidden
}
{{end}}{{/* /if .GenerateVisibleFlagInterface */}}

// GetCategory returns the category of the flag
func (f *{{.TypeName}}) GetCategory() string {
return f.Category
}

// GetUsage returns the usage string for the flag
func (f *{{.TypeName}}) GetUsage() string {
return f.Usage
}

// GetEnvVars returns the env vars for this flag
func (f *{{.TypeName}}) GetEnvVars() []string {
return f.EnvVars
}

// TakesValue returns true if the flag takes a value, otherwise false
func (f *{{.TypeName}}) TakesValue() bool {
return "{{.TypeName }}" != "BoolFlag"
}

{{end}}{{/* /if .GenerateFlagInterface */}}

{{end}}{{/* /range .SortedFlagTypes */}}

// vim{{/* 👻 */}}:ro
Expand Down
5 changes: 0 additions & 5 deletions cmd/urfave-cli-genflags/generated_altsrc.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

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
Expand Down
23 changes: 11 additions & 12 deletions cmd/urfave-cli-genflags/generated_test.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,30 @@ func Test{{.TypeName}}_SatisfiesFlagInterface(t *testing.T) {
_ = f.IsSet()
_ = f.Names()
}
{{end}}

{{if .GenerateFmtStringerInterface}}
func Test{{.TypeName}}_SatisfiesFmtStringerInterface(t *testing.T) {
var f fmt.Stringer = &{{$.UrfaveCLITestNamespace}}{{.TypeName}}{}

_ = f.String()
}
{{end}}

{{if .GenerateRequiredFlagInterface}}
func Test{{.TypeName}}_SatisfiesRequiredFlagInterface(t *testing.T) {
var f {{$.UrfaveCLITestNamespace}}RequiredFlag = &{{$.UrfaveCLITestNamespace}}{{.TypeName}}{}

_ = f.IsRequired()
}
{{end}}

{{if .GenerateVisibleFlagInterface}}
func Test{{.TypeName}}_SatisfiesVisibleFlagInterface(t *testing.T) {
var f {{$.UrfaveCLITestNamespace}}VisibleFlag = &{{$.UrfaveCLITestNamespace}}{{.TypeName}}{}

_ = f.IsVisible()
}

{{end}}

{{if .GenerateFmtStringerInterface}}
func Test{{.TypeName}}_SatisfiesFmtStringerInterface(t *testing.T) {
var f fmt.Stringer = &{{$.UrfaveCLITestNamespace}}{{.TypeName}}{}

_ = f.String()
}
{{end}}


{{end}}

// vim{{/* 👻 */}}:ro
Expand Down
2 changes: 1 addition & 1 deletion docs/v2/examples/flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ For example this:

<!-- {
"args": ["&#45;&#45;help"],
"output": ".*Load configuration from FILE\n.*Language for the greeting.*"
"output": ".*Load configuration from FILE\n.*\n.*Language for the greeting.*"
} -->
```go
package main
Expand Down
1 change: 1 addition & 0 deletions docs/v3/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# v3 guide
1 change: 1 addition & 0 deletions flag-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# `Spec` type that maps to this file structure.
flag_types:
bool:
no_default_text: true
struct_fields:
- name: Count
type: int
Expand Down
19 changes: 13 additions & 6 deletions flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,14 @@ type ActionableFlag interface {
// this interface be implemented.
type Flag interface {
fmt.Stringer

// Apply Flag settings to the given flag set
Apply(*flag.FlagSet) error

// All possible names for this flag
Names() []string

// Whether the flag has been set or not
IsSet() bool
}

Expand All @@ -108,6 +113,7 @@ type Flag interface {
type RequiredFlag interface {
Flag

// whether the flag is a required flag or not
IsRequired() bool
}

Expand Down Expand Up @@ -140,6 +146,12 @@ type DocGenerationSliceFlag interface {
IsSliceFlag() bool
}

// Countable is an interface to enable detection of flag values which support
// repetitive flags
type Countable interface {
Count() int
}

// VisibleFlag is an interface that allows to check if a flag is visible
type VisibleFlag interface {
Flag
Expand All @@ -153,15 +165,10 @@ type VisibleFlag interface {
type CategorizableFlag interface {
VisibleFlag

// Returns the category of the flag
GetCategory() string
}

// Countable is an interface to enable detection of flag values which support
// repetitive flags
type Countable interface {
Count() int
}

func flagSet(name string, flags []Flag) (*flag.FlagSet, error) {
set := flag.NewFlagSet(name, flag.ContinueOnError)

Expand Down
Loading