https://github.com/fgm/subcommands_demo
A tutorial for the github.com/google/subcommands package
https://github.com/fgm/subcommands_demo
cli cmd command-line-tool commands golang
Last synced: about 1 year ago
JSON representation
A tutorial for the github.com/google/subcommands package
- Host: GitHub
- URL: https://github.com/fgm/subcommands_demo
- Owner: fgm
- License: mit
- Created: 2022-02-25T09:27:05.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-03-03T16:39:03.000Z (over 4 years ago)
- Last Synced: 2025-04-22T23:07:12.631Z (about 1 year ago)
- Topics: cli, cmd, command-line-tool, commands, golang
- Homepage:
- Size: 38.1 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Multi-level demo for github.com/google/subcommands
This tutorial contains one branch per topic.
## Usage
Checkout each branch in turn to learn one level at a time.
- Ensure you have already installed:
- A working Go SDK
- The [`staticcheck`](https://staticcheck.io) linting tool
- The `make` command
- Run `make` to see the new features in that branch
## Contents
1. simple subcommands
1. basic usage with builtin commands
2. creating commands with the procedural API
3. passing non-CLI arguments
4. command groups
5. adding command flags
6. marking flags as important
2. reusing command code
3. commanders
1. procedural vs object API
2. creating commands with custom commanders
3. creating a testable command structure
4. creating nested commands
5. beyond `NewCommander`
1. controlling output
2. introspecting commanders
3. replacing builtins