Repository: urfave/cli
Pull request #1346 (2022-04-19 02:02:04)

Exclude hidden sub-command flags from docs
## What type of PR is this?

- bug

## What this PR does / why we need it:

Not sure I would hard-classify this as a "bug" per-se, but it expands on #999 by also excluding flags marked as `hidden` in sub-commands for docs generation.

## Which issue(s) this PR fixes:

Expands upon #999 

## Testing

I've changed `docs_test.go` and `go test ./...` passes.

## Release Notes

```release-note
NONE
```



Patch:
diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md
index b968075..bca4fea 100644
--- a/.github/ISSUE_TEMPLATE/question.md
+++ b/.github/ISSUE_TEMPLATE/question.md
@@ -1,10 +1,12 @@
 ---
 name: ask a question
-about: ask a question - assume stackoverflow's guidelines apply here
-title: your question title goes here
+about: ask us question - assume stackoverflow's guidelines apply here
+title: 'q: ( your question title goes here )'
 labels: 'kind/question, status/triage, area/v2'
 assignees: ''
 
 ---
 
-my question is...
+## my question is...
+
+_**( Put the question text here )**_
diff --git a/.github/ISSUE_TEMPLATE/v1-bug-report.md b/.github/ISSUE_TEMPLATE/v1-bug-report.md
index 1205d38..aabfe82 100644
--- a/.github/ISSUE_TEMPLATE/v1-bug-report.md
+++ b/.github/ISSUE_TEMPLATE/v1-bug-report.md
@@ -1,32 +1,28 @@
 ---
 name: v1 bug report
 about: Create a report to help us fix v1 bugs
-title: 'your bug title goes here'
+title: 'v1 bug: ( your bug title goes here )'
 labels: 'kind/bug, status/triage, area/v1'
 assignees: ''
 
 ---
 
-## My urfave/cli version is
+## my urfave/cli version is
 
 _**( Put the version of urfave/cli that you are using here )**_
 
 ## Checklist
 
-- [ ] Are you running the latest v1 release? The list of releases is [here](https://github.com/urfave/cli/releases).
-- [ ] Did you check the manual for your release? The v1 manual is [here](https://github.com/urfave/cli/blob/main/docs/v1/manual.md).
-- [ ] Did you perform a search about this problem? Here's the [Github guide](https://help.github.com/en/github/managing-your-work-on-github/using-search-to-filter-issues-and-pull-requests) about searching.
+* [ ] Are you running the latest v1 release? The list of releases is [here](https://github.com/urfave/cli/releases).
+* [ ] Did you check the manual for your release? The v1 manual is [here](https://github.com/urfave/cli/blob/master/docs/v1/manual.md)
+* [ ] Did you perform a search about this problem? Here's the [Github guide](https://help.github.com/en/github/managing-your-work-on-github/using-search-to-filter-issues-and-pull-requests) about searching.
 
 ## Dependency Management
 
-<!--
-  Delete any of the following that do not apply:
--->
-
-- My project is using go modules.
-- My project is using vendoring.
-- My project is automatically downloading the latest version.
-- I am unsure of what my dependency management setup is.
+- [ ] My project is using go modules.
+- [ ] My project is using vendoring.
+- [ ] My project is automatically downloading the latest version.
+- [ ] I am unsure of what my dependency management setup is.
 
 ## Describe the bug
 
@@ -38,30 +34,23 @@ Describe the steps or code required to reproduce the behavior
 
 ## Observed behavior
 
-What did you see happen immediately after the reproduction steps
-above?
+What did you see happen immediately after the reproduction steps above?
 
 ## Expected behavior
 
-What would you have expected to happen immediately after the
-reproduction steps above?
+What would you have expected to happen immediately after the reproduction steps above?
 
 ## Additional context
 
 Add any other context about the problem here.
 
-If the issue relates to a specific open source Github repo, please
-link that repo here.
+If the issue relates to a specific open source Github repo, please link that repo here.
 
-If you can reproduce this issue with a public CI system, please
-link a failing build here.
+If you can reproduce this issue with a public CI system, please link a failing build here.
 
 ## Want to fix this yourself?
 
-We'd love to have more contributors on this project! If the fix for
-this bug is easily explained and very small, free free to create a
-pull request for it. You'll want to base the PR off the `v1`
-branch, all `v1` bug fix releases will be made from that branch.
+We'd love to have more contributors on this project! If the fix for this bug is easily explained and very small, free free to create a pull request for it. You'll want to base the PR off the `v1` branch, all `v1` bug fix releases will be made from that branch.
 
 ## Run `go version` and paste its output here
 
diff --git a/.github/ISSUE_TEMPLATE/v2-bug-report.md b/.github/ISSUE_TEMPLATE/v2-bug-report.md
index 5c120e1..9944769 100644
--- a/.github/ISSUE_TEMPLATE/v2-bug-report.md
+++ b/.github/ISSUE_TEMPLATE/v2-bug-report.md
@@ -1,32 +1,28 @@
 ---
 name: v2 bug report
 about: Create a report to help us fix v2 bugs
-title: 'your bug title goes here'
+title: 'v2 bug: ( your bug title goes here )'
 labels: 'kind/bug, area/v2, status/triage'
 assignees: ''
 
 ---
 
-## My urfave/cli version is
+## my urfave/cli version is
 
 _**( Put the version of urfave/cli that you are using here )**_
 
 ## Checklist
 
-- [ ] Are you running the latest v2 release? The list of releases is [here](https://github.com/urfave/cli/releases).
-- [ ] Did you check the manual for your release? The v2 manual is [here](https://github.com/urfave/cli/blob/main/docs/v2/manual.md)
-- [ ] Did you perform a search about this problem? Here's the [Github guide](https://help.github.com/en/github/managing-your-work-on-github/using-search-to-filter-issues-and-pull-requests) about searching.
+* [ ] Are you running the latest v2 release? The list of releases is [here](https://github.com/urfave/cli/releases).
+* [ ] Did you check the manual for your release? The v2 manual is [here](https://github.com/urfave/cli/blob/master/docs/v2/manual.md)
+* [ ] Did you perform a search about this problem? Here's the [Github guide](https://help.github.com/en/github/managing-your-work-on-github/using-search-to-filter-issues-and-pull-requests) about searching.
 
 ## Dependency Management
 
-<!--
-  Delete any of the following that do not apply:
--->
-
-- My project is using go modules.
-- My project is using vendoring.
-- My project is automatically downloading the latest version.
-- I am unsure of what my dependency management setup is.
+- [ ] My project is using go modules.
+- [ ] My project is using vendoring.
+- [ ] My project is automatically downloading the latest version.
+- [ ] I am unsure of what my dependency management setup is.
 
 ## Describe the bug
 
@@ -38,30 +34,23 @@ Describe the steps or code required to reproduce the behavior
 
 ## Observed behavior
 
-What did you see happen immediately after the reproduction steps
-above?
+What did you see happen immediately after the reproduction steps above?
 
 ## Expected behavior
 
-What would you have expected to happen immediately after the
-reproduction steps above?
+What would you have expected to happen immediately after the reproduction steps above?
 
 ## Additional context
 
 Add any other context about the problem here.
 
-If the issue relates to a specific open source Github repo, please
-link that repo here.
+If the issue relates to a specific open source Github repo, please link that repo here.
 
-If you can reproduce this issue with a public CI system, please
-link a failing build here.
+If you can reproduce this issue with a public CI system, please link a failing build here.
 
 ## Want to fix this yourself?
 
-We'd love to have more contributors on this project! If the fix for
-this bug is easily explained and very small, free free to create a
-pull request for it.
-
+We'd love to have more contributors on this project! If the fix for this bug is easily explained and very small, free free to create a pull request for it.
 ## Run `go version` and paste its output here
 
 ```
diff --git a/.github/ISSUE_TEMPLATE/v2-feature-request.md b/.github/ISSUE_TEMPLATE/v2-feature-request.md
index 2b1e727..bc527b1 100644
--- a/.github/ISSUE_TEMPLATE/v2-feature-request.md
+++ b/.github/ISSUE_TEMPLATE/v2-feature-request.md
@@ -1,7 +1,7 @@
 ---
 name: v2 feature request
 about: Suggest an improvement for v2
-title: 'your feature title goes here'
+title: 'v2 feature: ( your feature title goes here )'
 labels: 'type/feature, area/v2, status/triage'
 assignees: ''
 
@@ -10,19 +10,16 @@ assignees: ''
 ## Checklist
 
 * [ ] Are you running the latest v2 release? The list of releases is [here](https://github.com/urfave/cli/releases).
-* [ ] Did you check the manual for your release? The v2 manual is [here](https://github.com/urfave/cli/blob/main/docs/v2/manual.md).
+* [ ] Did you check the manual for your release? The v2 manual is [here](https://github.com/urfave/cli/blob/master/docs/v2/manual.md)
 * [ ] Did you perform a search about this feature? Here's the [Github guide](https://help.github.com/en/github/managing-your-work-on-github/using-search-to-filter-issues-and-pull-requests) about searching.
 
 ## What problem does this solve?
 
 A clear and concise description of what problem this feature would solve. For example:
 
-- needing to type out the full flag name takes a long time, so I
-  would like to suggest adding auto-complete
-- I use (osx, windows, linux) and would like support for (some
-  existing feature) to be extended to my platform
-- the terminal output for a particular error case is confusing, and
-  I think it could be improved
+- needing to type out the full flag name takes a long time, so I would like to suggest adding auto-complete
+- I use (osx, windows, linux) and would like support for (some existing feature) to be extended to my platform
+- the terminal output for a particular error case is confusing, and I think it could be improved
 
 ## Solution description
 
@@ -30,5 +27,4 @@ A detailed description of what you want to happen.
 
 ## Describe alternatives you've considered
 
-A clear and concise description of any alternative solutions or
-features you've considered.
+A clear and concise description of any alternative solutions or features you've considered.
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index 47348f8..4e76725 100644
--- a/.github/pull_request_template.md
+++ b/.github/pull_request_template.md
@@ -8,14 +8,10 @@
 
 _(REQUIRED)_
 
-<!--
-  Delete any of the following that do not apply:
- -->
-
-- bug
-- cleanup
-- documentation
-- feature
+- [ ] bug
+- [ ] cleanup  
+- [ ] documentation
+- [ ] feature
 
 ## What this PR does / why we need it:
 
@@ -32,7 +28,6 @@ _(REQUIRED)_
 ## Which issue(s) this PR fixes:
 
 _(REQUIRED)_
-
 <!--
 If this PR fixes one of more issues, list them here.
 One line each, like so:
diff --git a/.github/stale.yml b/.github/stale.yml
deleted file mode 100644
index f050e9b..0000000
--- a/.github/stale.yml
+++ /dev/null
@@ -1,17 +0,0 @@
-# Number of days of inactivity before an issue becomes stale
-daysUntilStale: 365
-# Number of days of inactivity before a stale issue is closed
-daysUntilClose: 90
-# Issues with these labels will never be considered stale
-exemptLabels:
-  - pinned
-  - security
-# Label to use when marking an issue as stale
-staleLabel: wontfix
-# Comment to post when marking an issue as stale. Set to `false` to disable
-markComment: >
-  This issue has been automatically marked as stale because it has not had
-  recent activity. It will be closed if no further activity occurs. Thank you
-  for your contributions.
-# Comment to post when closing a stale issue. Set to `false` to disable
-closeComment: false
diff --git a/.github/workflows/cli.yml b/.github/workflows/cli.yml
index e9a45c2..e3b7a97 100644
--- a/.github/workflows/cli.yml
+++ b/.github/workflows/cli.yml
@@ -3,35 +3,42 @@ name: Run Tests
 on:
   push:
     branches:
-      - main
-    tags:
-      - v2.*
+      - master
+      - v1
   pull_request:
     branches:
-      - main
+      - master
+      - v1
 
 jobs:
   test:
     strategy:
       matrix:
         os: [ubuntu-latest, macos-latest, windows-latest]
-        go: [1.16.x, 1.17.x, 1.18.x]
+        go: [1.15, 1.16, 1.17]
     name: ${{ matrix.os }} @ Go ${{ matrix.go }}
     runs-on: ${{ matrix.os }}
     steps:
       - name: Set up Go ${{ matrix.go }}
-        uses: actions/setup-go@v3
+        uses: actions/setup-go@v1
         with:
           go-version: ${{ matrix.go }}
 
-      - name: Set PATH
-        run: echo "${GITHUB_WORKSPACE}/.local/bin" >>"${GITHUB_PATH}"
+      - name: Set GOPATH, PATH and ENV
+        run: |
+          echo "GOPATH=$(dirname $GITHUB_WORKSPACE)" >> $GITHUB_ENV
+          echo "GO111MODULE=on" >> $GITHUB_ENV
+          echo "GOPROXY=https://proxy.golang.org" >> $GITHUB_ENV
+          echo "$(dirname $GITHUB_WORKSPACE)/bin" >> $GITHUB_PATH
+        shell: bash
 
       - name: Checkout Code
-        uses: actions/checkout@v3
+        uses: actions/checkout@v1
+        with:
+          ref: ${{ github.ref }}
 
       - name: GOFMT Check
-        if: matrix.go == '1.17.x' && matrix.os == 'ubuntu-latest'
+        if: matrix.go == 1.17 && matrix.os == 'ubuntu-latest'
         run: test -z $(gofmt -l .)
 
       - name: vet
@@ -44,8 +51,8 @@ jobs:
         run: go run internal/build/build.go check-binary-size
 
       - name: Upload coverage to Codecov
-        if: success() && matrix.go == '1.17.x' && matrix.os == 'ubuntu-latest'
-        uses: codecov/codecov-action@v2
+        if: success() && matrix.go == 1.17 && matrix.os == 'ubuntu-latest'
+        uses: codecov/codecov-action@v1
         with:
           fail_ci_if_error: true
 
@@ -54,30 +61,44 @@ jobs:
     runs-on: ubuntu-latest
     steps:
       - name: Set up Go
-        uses: actions/setup-go@v3
+        uses: actions/setup-go@v1
         with:
-          go-version: 1.18.x
+          # Currently fails on 1.16+
+          go-version: 1.15
 
-      - name: Use Node.js 16
-        uses: actions/setup-node@v3
+      - name: Use Node.js 12.x
+        uses: actions/setup-node@v1
         with:
-          node-version: '16'
+          node-version: 12.x
 
-      - name: Set PATH
-        run: echo "${GITHUB_WORKSPACE}/.local/bin" >>"${GITHUB_PATH}"
+      - name: Set GOPATH, PATH and ENV
+        run: |
+          echo "GOPATH=$(dirname $GITHUB_WORKSPACE)" >> $GITHUB_ENV
+          echo "GO111MODULE=on" >> $GITHUB_ENV
+          echo "GOPROXY=https://proxy.golang.org" >> $GITHUB_ENV
+          echo "$(dirname $GITHUB_WORKSPACE)/bin" >> $GITHUB_PATH
+        shell: bash
 
       - name: Checkout Code
-        uses: actions/checkout@v3
+        uses: actions/checkout@v1
+        with:
+          ref: ${{ github.ref }}
 
       - name: Install Dependencies
-        run:
-          mkdir -p "${GITHUB_WORKSPACE}/.local/bin" &&
-          curl -fsSL -o "${GITHUB_WORKSPACE}/.local/bin/gfmrun" "https://github.com/urfave/gfmrun/releases/download/v1.3.0/gfmrun-$(go env GOOS)-$(go env GOARCH)-v1.3.0" &&
-          chmod +x "${GITHUB_WORKSPACE}/.local/bin/gfmrun" &&
+        run: |
+          mkdir -p $GOPATH/bin
+          curl -L -o $GOPATH/bin/gfmrun "https://github.com/urfave/gfmrun/releases/download/v1.2.14/gfmrun-$(go env GOOS)-amd64-v1.2.14"
+          chmod +x $GOPATH/bin/gfmrun
           npm install -g markdown-toc@1.2.0
 
-      - name: gfmrun
-        run: go run internal/build/build.go gfmrun docs/v2/manual.md
-
-      - name: toc
-        run: go run internal/build/build.go toc docs/v2/manual.md
+      - name: Run Tests (v1)
+        if: contains(github.base_ref, 'v1')
+        run: |
+          go run internal/build/build.go gfmrun docs/v1/manual.md
+          go run internal/build/build.go toc docs/v1/manual.md
+
+      - name: Run Tests (v2)
+        if: contains(github.base_ref, 'master')
+        run: |
+          go run internal/build/build.go gfmrun docs/v2/manual.md
+          go run internal/build/build.go toc docs/v2/manual.md
diff --git a/.gitignore b/.gitignore
index e0c50ab..afdca41 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,5 @@ vendor
 .idea
 internal/*/built-example
 coverage.txt
-/.local/
 
 *.exe
diff --git a/README.md b/README.md
index 5b8d2b6..2b74f1f 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@ cli
 [![GoDoc](https://godoc.org/github.com/urfave/cli?status.svg)](https://pkg.go.dev/github.com/urfave/cli/v2)
 [![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)
+[![codecov](https://codecov.io/gh/urfave/cli/branch/master/graph/badge.svg)](https://codecov.io/gh/urfave/cli)
 
 cli is a simple, fast, and fun package for building command line apps in Go. The
 goal is to enable developers to write fast and distributable command line
@@ -12,7 +12,7 @@ applications in an expressive way.
 
 ## Usage Documentation
 
-Usage documentation exists for each major version. Don't know what version you're on? You're probably using the version from the `main` branch, which is currently `v2`.
+Usage documentation exists for each major version. Don't know what version you're on? You're probably using the version from the `master` branch, which is currently `v2`.
 
 - `v2` - [./docs/v2/manual.md](./docs/v2/manual.md)
 - `v1` - [./docs/v1/manual.md](./docs/v1/manual.md)
@@ -30,7 +30,7 @@ Go Modules are required when using this package. [See the go blog guide on using
 ### Using `v2` releases
 
 ```
-$ go get github.com/urfave/cli/v2
+$ GO111MODULE=on go get github.com/urfave/cli/v2
 ```
 
 ```go
@@ -44,7 +44,7 @@ import (
 ### Using `v1` releases
 
 ```
-$ go get github.com/urfave/cli
+$ GO111MODULE=on go get github.com/urfave/cli
 ```
 
 ```go
@@ -67,4 +67,4 @@ export PATH=$PATH:$GOPATH/bin
 
 cli is tested against multiple versions of Go on Linux, and against the latest
 released version of Go on OS X and Windows. This project uses Github Actions for
-builds. To see our currently supported go versions and platforms, look at the [./.github/workflows/cli.yml](https://github.com/urfave/cli/blob/main/.github/workflows/cli.yml).
+builds. To see our currently supported go versions and platforms, look at the [./.github/workflows/cli.yml](https://github.com/urfave/cli/blob/master/.github/workflows/cli.yml).
diff --git a/app.go b/app.go
index 6abcc08..5c616e6 100644
--- a/app.go
+++ b/app.go
@@ -12,7 +12,7 @@ import (
 )
 
 var (
-	changeLogURL            = "https://github.com/urfave/cli/blob/main/docs/CHANGELOG.md"
+	changeLogURL            = "https://github.com/urfave/cli/blob/master/docs/CHANGELOG.md"
 	appActionDeprecationURL = fmt.Sprintf("%s#deprecated-cli-app-action-signature", changeLogURL)
 	contactSysadmin         = "This is an error in the application.  Please contact the distributor of this application if this is not you."
 	errInvalidActionType    = NewExitError("ERROR invalid Action type. "+
diff --git a/docs.go b/docs.go
index 9f82fc6..e6f0265 100644
--- a/docs.go
+++ b/docs.go
@@ -80,14 +80,14 @@ func prepareCommands(commands []*Command, level int) []string {
 			usageText,
 		)
 
-		flags := prepareArgsWithValues(command.Flags)
+		flags := prepareArgsWithValues(command.VisibleFlags())
 		if len(flags) > 0 {
 			prepared += fmt.Sprintf("\n%s", strings.Join(flags, "\n"))
 		}
 
 		coms = append(coms, prepared)
 
-		// recursevly iterate subcommands
+		// recursively iterate subcommands
 		if len(command.Subcommands) > 0 {
 			coms = append(
 				coms,
diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md
index 41671a9..9a4640a 100644
--- a/docs/CONTRIBUTING.md
+++ b/docs/CONTRIBUTING.md
@@ -6,7 +6,7 @@ Feel free to put up a pull request to fix a bug or maybe add a feature. We will
 give it a code review and make sure that it does not break backwards
 compatibility. If collaborators agree that it is in line with
 the vision of the project, we will work with you to get the code into
-a mergeable state and merge it into the main branch.
+a mergeable state and merge it into the master branch.
 
 If you have contributed something significant to the project, we will most
 likely add you as a collaborator. As a collaborator you are given the ability
diff --git a/docs/v2/manual.md b/docs/v2/manual.md
index b480dd6..56be65b 100644
--- a/docs/v2/manual.md
+++ b/docs/v2/manual.md
@@ -674,10 +674,8 @@ Take for example this app that requires the `lang` flag:
 package main
 
 import (
-  "fmt"
   "log"
   "os"
-
   "github.com/urfave/cli/v2"
 )
 
diff --git a/fish.go b/fish.go
index 588e070..eec3253 100644
--- a/fish.go
+++ b/fish.go
@@ -95,7 +95,7 @@ func (a *App) prepareFishCommands(commands []*Command, allCommands *[]string, pr
 		completions = append(completions, completion.String())
 		completions = append(
 			completions,
-			a.prepareFishFlags(command.Flags, command.Names())...,
+			a.prepareFishFlags(command.VisibleFlags(), command.Names())...,
 		)
 
 		// recursevly iterate subcommands


Test patch:
diff --git a/docs_test.go b/docs_test.go
index adccbbb..ad714e5 100644
--- a/docs_test.go
+++ b/docs_test.go
@@ -103,6 +103,11 @@ Should be a part of the same code block
 					Aliases: []string{"s"},
 					Usage:   "some usage text",
 				},
+				&StringFlag{
+					Name:   "sub-command-hidden-flag",
+					Usage:  "some hidden usage text",
+					Hidden: true,
+				},
 			},
 			Name:      "sub-usage",
 			Usage:     "standard usage text",