-
Notifications
You must be signed in to change notification settings - Fork 0
docs: add comprehensive help output #69
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
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
58fc970
small changes to docs and error messages
dwilding 786ed8d
expand help output
dwilding faed783
Merge remote-tracking branch 'origin/main' into cli-help
dwilding f5f1241
fix grammar
dwilding d018041
add help output to README
dwilding c28edec
make help output more readable
dwilding 7fd7043
small tweaks to help output
dwilding 0836a63
Merge remote-tracking branch 'origin/main' into cli-help
dwilding b396006
remove double blank lines
dwilding 56fb2b0
add missing comma in pyproject.toml
dwilding b49adac
add check for the command reference in README.md
dwilding f4a0dfc
update pre-commit config
dwilding e7e1b51
remove one more blank line
dwilding b535f9b
add script needed by new check
dwilding File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 @@ | ||
| """Extracts gimmegit's help output from the "Command reference" section of README.md.""" | ||
|
|
||
| from pathlib import Path | ||
|
|
||
|
|
||
| def main() -> None: | ||
| text = Path("README.md").read_text() | ||
| start_marker = "# Command reference\n\n```text\n" | ||
| start_index = text.find(start_marker) | ||
| assert start_index > 0 | ||
| start_index += len(start_marker) | ||
| end_index = text.find("\n```", start_index) | ||
| assert end_index > start_index | ||
dwilding marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| print(text[start_index:end_index]) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -38,5 +38,5 @@ line-length = 99 | |
| root = [ | ||
| "./src", | ||
| "./tests/functional", | ||
| "./tests/unit" | ||
| "./tests/unit", | ||
| ] | ||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,18 +1,112 @@ | ||
| help = """\ | ||
| Usage: | ||
| gimmegit [<options>] <repo> [<new-branch>] [-- <git-options>] | ||
| gimmegit [<options>] <branch-url> [-- <git-options>] | ||
| gimmegit is a tool for cloning GitHub repos and creating branches. gimmegit puts each clone | ||
| in a dedicated directory, based on the project, owner, and branch name. | ||
|
|
||
| Show status: | ||
| gimmegit [--color {auto,always,never}] | ||
| ▶ USAGE | ||
|
|
||
| Additional commands: | ||
| gimmegit -c | ||
| gimmegit --compare | ||
| gimmegit [<options>] <repo> [<new-branch>] [-- <git-options>] (1) | ||
| gimmegit [<options>] <branch-url> [-- <git-options>] (2) | ||
|
|
||
| gimmegit -h | ||
| gimmegit --help | ||
| 1. Clone a GitHub repo and check out a new branch. | ||
| <repo> is one of: | ||
| • <owner>/<project>. For example, 'dwilding/frogtab'. <owner> is optional if the | ||
| GIMMEGIT_GITHUB_TOKEN environment variable contains a personal access token. | ||
| • A repo URL. For example, 'https://github.com/dwilding/frogtab'. | ||
| <new-branch> is the name of a branch that doesn't already exist. gimmegit generates a | ||
| branch name if you omit <new-branch>. For example, 'snapshot0801' on August 1. | ||
|
|
||
| gimmegit --version | ||
| 2. Clone a GitHub repo and check out an existing branch. | ||
| <branch-url> is a URL such as 'https://github.com/dwilding/frogtab/tree/fix-something'. | ||
|
|
||
| gimmegit [--ssh {auto,always,never}] --parse-url <url>""" | ||
| ▶ DIRECTORY STRUCTURE | ||
|
|
||
| When you clone a repo, gimmegit creates a dedicated directory for the clone: | ||
| . | ||
| └── <project> The project directory. For example, 'frogtab'. | ||
| └── <owner>-<branch> The clone directory. For example, 'dwilding-my-feature'. | ||
|
|
||
| If the clone directory already exists, gimmegit skips cloning. If the clone directory would | ||
| be inside an existing repo, gimmegit exits with an error. gimmegit also exits with an error | ||
| if it detects that the working directory is a project directory (specifically, if the latest | ||
| modified subdirectory is a gimmegit clone). | ||
|
|
||
| ▶ BRANCH MAPPING | ||
|
|
||
| gimmegit creates a Git alias 'update-branch' that merges remote changes from the base branch. | ||
| The base branch is the repo's main branch. If the repo is a fork and GIMMEGIT_GITHUB_TOKEN is | ||
| set, the base branch is the upstream version of the repo's main branch. | ||
|
|
||
| For new branches: | ||
| • gimmegit branches off the base branch. | ||
| • gimmegit doesn't push the branch to GitHub. | ||
|
|
||
| ▶ OPTIONS | ||
|
|
||
| -u, --upstream-owner <owner> Owner of the base branch. For example, provide '-u canonical' | ||
| to clone a fork of a repo from https://github.com/canonical. | ||
| If you provide -u, gimmegit doesn't try to use | ||
| GIMMEGIT_GITHUB_TOKEN to look for an upstream repo. | ||
|
|
||
| -b, --base-branch <name|url> Name or URL of the base branch. If '-b <name>', gimmegit uses | ||
| <name> instead of the repo's main branch (or upstream main). | ||
| If '-b https://github.com/<owner>/<project>/tree/<name>', | ||
| gimmegit sets the base branch and ignores -u. | ||
|
|
||
| --no-pre-commit Don't try to install a pre-commit hook after cloning the repo. | ||
|
|
||
| --allow-outer-repo Allow the clone directory to be inside a repo. | ||
|
|
||
| --force-project-dir Create the project directory even if gimmegit finds a gimmegit | ||
| clone in the working directory. | ||
|
|
||
| --ssh auto|always|never Controls whether Git remotes use SSH or HTTPS. | ||
| • auto (default): Use SSH if ~/.ssh contains an SSH key. | ||
|
|
||
| --color auto|always|never Controls whether the output has colored text. | ||
| • auto (default): Use colors if the NO_COLOR environment | ||
| variable is empty and the output is going to a terminal. | ||
|
|
||
| --return-dir Output the clone directory path to stdout and send full | ||
| progress to stderr. | ||
|
|
||
| ▶ GIT OPTIONS | ||
|
|
||
| gimmegit sets --no-tags when cloning. Use '-- <git-options>' to provide extra clone options. | ||
| For example, use '-- --tags' to clone tags. | ||
|
|
||
| ▶ PRE-COMMIT | ||
|
|
||
| If the repo contains a file '.pre-commit-config.yaml', gimmegit installs a pre-commit hook | ||
| after cloning the repo. For more information, see https://pre-commit.com/. | ||
|
|
||
| ▶ ADDITIONAL COMMANDS | ||
|
|
||
| gimmegit [--color auto|always|never] (1) | ||
| gimmegit -c | --compare (2) | ||
| gimmegit -h | --help (3) | ||
| gimmegit --version (4) | ||
| gimmegit [--ssh auto|always|never] --parse-url <url> (5) | ||
|
|
||
| 1. Display the branch mapping if the working directory is inside a gimmegit clone. | ||
| 2. Compare branches in GitHub if the working directory is inside a gimmegit clone. | ||
| 3. Display a summary of how to use gimmegit. | ||
| 4. Display the installed version of gimmegit. | ||
| 5. Display a JSON representation of a GitHub URL. Intended for extensions to gimmegit. | ||
|
|
||
| ▶ EXAMPLES | ||
|
|
||
| gimmegit dwilding/frogtab my-feature (1) | ||
| gimmegit -b candidate dwilding/frogtab bump-version (2) | ||
| gimmegit https://github.com/dwilding/frogtab/tree/fix-something (3) | ||
| gimmegit -u canonical dwilding/operator update-docs (4) | ||
| gimmegit -b 2.23-maintenance -u canonical dwilding/operator backport-docs (5) | ||
| gimmegit -b https://github.com/canonical/operator/tree/2.23-maintenance \\ (6) | ||
| dwilding/operator backport-docs | ||
|
|
||
| 1. Clone https://github.com/dwilding/frogtab and check out a new branch, branching off main. | ||
| 2. Clone the same repo and check out a new branch, branching off a dev branch. | ||
| 3. Clone the same repo and check out an existing branch. | ||
| 4. Clone dwilding's fork of https://github.com/canonical/operator and check out a new branch, | ||
| branching off upstream main. | ||
| 5. Clone the same fork and check out a new branch, branching off an upstream dev branch. | ||
| 6. Equivalent to (5).""" |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.