···11+# Auto detect text files and perform LF normalization
22+* text=auto
+216
.gitignore
···11+# Created by https://www.toptal.com/developers/gitignore/api/macos,windows,linux,visualstudiocode,jetbrains+all,go
22+# Edit at https://www.toptal.com/developers/gitignore?templates=macos,windows,linux,visualstudiocode,jetbrains+all,go
33+44+### Go ###
55+# If you prefer the allow list template instead of the deny list, see community template:
66+# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
77+#
88+# Binaries for programs and plugins
99+*.exe
1010+*.exe~
1111+*.dll
1212+*.so
1313+*.dylib
1414+1515+# Test binary, built with `go test -c`
1616+*.test
1717+1818+# Output of the go coverage tool, specifically when used with LiteIDE
1919+*.out
2020+coverage.html
2121+2222+# Taskfile
2323+.task
2424+2525+# Comparative benchmarks
2626+before.txt
2727+after.txt
2828+2929+# Dependency directories (remove the comment below to include it)
3030+# vendor/
3131+3232+# Go workspace file
3333+go.work
3434+3535+### JetBrains+all ###
3636+# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
3737+# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
3838+3939+# User-specific stuff
4040+.idea/**/workspace.xml
4141+.idea/**/tasks.xml
4242+.idea/**/usage.statistics.xml
4343+.idea/**/dictionaries
4444+.idea/**/shelf
4545+4646+# AWS User-specific
4747+.idea/**/aws.xml
4848+4949+# Generated files
5050+.idea/**/contentModel.xml
5151+5252+# Sensitive or high-churn files
5353+.idea/**/dataSources/
5454+.idea/**/dataSources.ids
5555+.idea/**/dataSources.local.xml
5656+.idea/**/sqlDataSources.xml
5757+.idea/**/dynamic.xml
5858+.idea/**/uiDesigner.xml
5959+.idea/**/dbnavigator.xml
6060+6161+# Gradle
6262+.idea/**/gradle.xml
6363+.idea/**/libraries
6464+6565+# Gradle and Maven with auto-import
6666+# When using Gradle or Maven with auto-import, you should exclude module files,
6767+# since they will be recreated, and may cause churn. Uncomment if using
6868+# auto-import.
6969+# .idea/artifacts
7070+# .idea/compiler.xml
7171+# .idea/jarRepositories.xml
7272+# .idea/modules.xml
7373+# .idea/*.iml
7474+# .idea/modules
7575+# *.iml
7676+# *.ipr
7777+7878+# CMake
7979+cmake-build-*/
8080+8181+# Mongo Explorer plugin
8282+.idea/**/mongoSettings.xml
8383+8484+# File-based project format
8585+*.iws
8686+8787+# IntelliJ
8888+out/
8989+9090+# mpeltonen/sbt-idea plugin
9191+.idea_modules/
9292+9393+# JIRA plugin
9494+atlassian-ide-plugin.xml
9595+9696+# Cursive Clojure plugin
9797+.idea/replstate.xml
9898+9999+# SonarLint plugin
100100+.idea/sonarlint/
101101+102102+# Crashlytics plugin (for Android Studio and IntelliJ)
103103+com_crashlytics_export_strings.xml
104104+crashlytics.properties
105105+crashlytics-build.properties
106106+fabric.properties
107107+108108+# Editor-based Rest Client
109109+.idea/httpRequests
110110+111111+# Android studio 3.1+ serialized cache file
112112+.idea/caches/build_file_checksums.ser
113113+114114+### JetBrains+all Patch ###
115115+# Ignore everything but code style settings and run configurations
116116+# that are supposed to be shared within teams.
117117+118118+.idea/*
119119+120120+!.idea/codeStyles
121121+!.idea/runConfigurations
122122+123123+### Linux ###
124124+*~
125125+126126+# temporary files which can be created if a process still has a handle open of a deleted file
127127+.fuse_hidden*
128128+129129+# KDE directory preferences
130130+.directory
131131+132132+# Linux trash folder which might appear on any partition or disk
133133+.Trash-*
134134+135135+# .nfs files are created when an open file is removed but is still being accessed
136136+.nfs*
137137+138138+### macOS ###
139139+# General
140140+.DS_Store
141141+.AppleDouble
142142+.LSOverride
143143+144144+# Icon must end with two \r
145145+Icon
146146+147147+148148+# Thumbnails
149149+._*
150150+151151+# Files that might appear in the root of a volume
152152+.DocumentRevisions-V100
153153+.fseventsd
154154+.Spotlight-V100
155155+.TemporaryItems
156156+.Trashes
157157+.VolumeIcon.icns
158158+.com.apple.timemachine.donotpresent
159159+160160+# Directories potentially created on remote AFP share
161161+.AppleDB
162162+.AppleDesktop
163163+Network Trash Folder
164164+Temporary Items
165165+.apdisk
166166+167167+### macOS Patch ###
168168+# iCloud generated files
169169+*.icloud
170170+171171+### VisualStudioCode ###
172172+.vscode/*
173173+!.vscode/settings.json
174174+!.vscode/tasks.json
175175+!.vscode/launch.json
176176+!.vscode/extensions.json
177177+!.vscode/*.code-snippets
178178+179179+# Local History for Visual Studio Code
180180+.history/
181181+182182+# Built Visual Studio Code Extensions
183183+*.vsix
184184+185185+### VisualStudioCode Patch ###
186186+# Ignore all local history of files
187187+.history
188188+.ionide
189189+190190+### Windows ###
191191+# Windows thumbnail cache files
192192+Thumbs.db
193193+Thumbs.db:encryptable
194194+ehthumbs.db
195195+ehthumbs_vista.db
196196+197197+# Dump file
198198+*.stackdump
199199+200200+# Folder config file
201201+[Dd]esktop.ini
202202+203203+# Recycle Bin used on file shares
204204+$RECYCLE.BIN/
205205+206206+# Windows Installer files
207207+*.cab
208208+*.msi
209209+*.msix
210210+*.msm
211211+*.msp
212212+213213+# Windows shortcuts
214214+*.lnk
215215+216216+# End of https://www.toptal.com/developers/gitignore/api/macos,windows,linux,visualstudiocode,jetbrains+all,go
···11+22+MIT License
33+44+Copyright (c) 2024, Tom Fleet
55+66+Permission is hereby granted, free of charge, to any person obtaining a copy
77+of this software and associated documentation files (the "Software"), to deal
88+in the Software without restriction, including without limitation the rights
99+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1010+copies of the Software, and to permit persons to whom the Software is
1111+furnished to do so, subject to the following conditions:
1212+1313+The above copyright notice and this permission notice shall be included in all
1414+copies or substantial portions of the Software.
1515+1616+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1717+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1818+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1919+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2020+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2121+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222+SOFTWARE.
+40
README.md
···11+# CLI
22+33+[](https://github.com/FollowTheProcess/cli)
44+[](https://pkg.go.dev/github.com/FollowTheProcess/cli)
55+[](https://goreportcard.com/report/github.com/FollowTheProcess/cli)
66+[](https://github.com/FollowTheProcess/cli)
77+[](https://github.com/FollowTheProcess/cli/actions?query=workflow%3ACI)
88+[](https://codecov.io/gh/FollowTheProcess/cli)
99+1010+Tiny, simple, minimal CLI framework for Go
1111+1212+> [!WARNING]
1313+> **CLI is in early development and is not yet ready for use**
1414+1515+## Project Description
1616+1717+`cli` is my attempt at making a very simple, minimalist, yet functional and powerful CLI framework for Go. Inspired by things like <https://github.com/spf13/cobra> and <https://github.com/urfave/cli>.
1818+1919+*"So why make a new one?"*
2020+2121+Good question 🤔
2222+2323+1) I love Cobra and use it in a lot of my own programs, but IMO it's unnecessarily complex. The `Command` struct has lots of fields, has many ways to do things, and a lot of options I never use. It's a fantastic library, but has suffered from success in the sense that everybody wants it to do everything, rather than remaining tightly focussed on the essentials
2424+2) I feel like now we have generics and some other cool modern Go idioms, a CLI toolkit could be better designed and have a friendlier API, with less options and one clear way to do things
2525+3) It's fun to implement cool things from scratch and stretch your programming legs on a new problem
2626+2727+## Installation
2828+2929+```shell
3030+go get github.com/FollowTheProcess/cli@latest
3131+```
3232+3333+## Quickstart
3434+3535+### Credits
3636+3737+This package was created with [copier] and the [FollowTheProcess/go_copier] project template.
3838+3939+[copier]: https://copier.readthedocs.io/en/stable/
4040+[FollowTheProcess/go_copier]: https://github.com/FollowTheProcess/go_copier
+66
Taskfile.yml
···11+# https://taskfile.dev
22+33+version: "3"
44+55+vars:
66+ COV_DATA: coverage.out
77+88+tasks:
99+ default:
1010+ desc: List all available tasks
1111+ silent: true
1212+ cmd: task --list
1313+1414+ tidy:
1515+ desc: Tidy dependencies in go.mod and go.sum
1616+ cmd: go mod tidy
1717+1818+ fmt:
1919+ desc: Run go fmt on all source files
2020+ cmd: go fmt ./...
2121+2222+ test:
2323+ desc: Run the test suite
2424+ cmd: go test -race ./... {{ .CLI_ARGS }}
2525+2626+ bench:
2727+ desc: Run all project benchmarks
2828+ cmd: go test ./... -run None -benchmem -bench . {{ .CLI_ARGS }}
2929+3030+ lint:
3131+ desc: Run the linters and auto-fix if possible
3232+ cmd: golangci-lint run --fix
3333+ preconditions:
3434+ - sh: command -v golangci-lint
3535+ msg: golangci-lint not installed, see https://golangci-lint.run/usage/install/#local-installation
3636+3737+ doc:
3838+ desc: Render the pkg docs locally
3939+ cmd: pkgsite -open
4040+ preconditions:
4141+ - sh: command -v pkgsite
4242+ msg: pkgsite not installed, run go install golang.org/x/pkgsite/cmd/pkgsite@latest
4343+4444+ cov:
4545+ desc: Calculate test coverage and render the html
4646+ generates:
4747+ - "{{ .COV_DATA }}"
4848+ cmds:
4949+ - go test -race -cover -covermode atomic -coverprofile {{ .COV_DATA }} ./...
5050+ - go tool cover -html {{ .COV_DATA }}
5151+5252+ check:
5353+ desc: Run tests and linting in one
5454+ cmds:
5555+ - task: test
5656+ - task: lint
5757+5858+ sloc:
5959+ desc: Print lines of code
6060+ cmd: fd . -e go | xargs wc -l | sort -nr | head
6161+6262+ clean:
6363+ desc: Remove build artifacts and other clutter
6464+ cmds:
6565+ - go clean ./...
6666+ - rm -rf {{ .COV_DATA }}
+7
cli.go
···11+// Package cli is a placeholder for something cool.
22+package cli
33+44+// Hello returns a welcome message for the project.
55+func Hello() string {
66+ return "Hello cli"
77+}
···11+<!-- Provide a brief summary of your changes in the Title above -->
22+33+#### Description
44+<!-- Describe your changes in detail -->
55+66+#### Motivation and Context
77+<!-- Why is this change required? What problem does it solve? -->
88+<!-- If it fixes an open issue, please link to the issue here. -->
99+Closes #
1010+1111+#### How Has This Been Tested?
1212+<!-- Please describe in detail how you tested your changes. -->
1313+<!-- Include details of your testing environment, tests ran to see how -->
1414+<!-- your change affects other areas of the code, etc. -->
1515+1616+#### Checklist
1717+<!-- Go over all the following points, and put an `x` in all the boxes that apply. -->
1818+<!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
1919+- [ ] I have updated the documentation if needed.
2020+- [ ] I have updated the tests if needed.
···11+name: 🐞 Bug Report
22+description: File a bug/issue
33+title: "<title>"
44+labels:
55+ - bug
66+77+body:
88+ - type: checkboxes
99+ attributes:
1010+ label: Is there an existing issue for this?
1111+ description: Please search to see if an issue already exists for the bug you encountered.
1212+ options:
1313+ - label: I have searched the existing issues
1414+ required: true
1515+1616+ - type: textarea
1717+ attributes:
1818+ label: Current Behavior
1919+ description: A concise description of what you're experiencing.
2020+ validations:
2121+ required: false
2222+2323+ - type: textarea
2424+ attributes:
2525+ label: Expected Behavior
2626+ description: A concise description of what you expected to happen.
2727+ validations:
2828+ required: false
2929+3030+ - type: textarea
3131+ attributes:
3232+ label: Steps To Reproduce
3333+ description: Steps to reproduce the behavior.
3434+ placeholder: |
3535+ 1. In this environment...
3636+ 2. With this config...
3737+ 3. Run '...'
3838+ 4. See error...
3939+ validations:
4040+ required: false
4141+4242+ - type: textarea
4343+ attributes:
4444+ label: Environment
4545+ description: |
4646+ Please describe your execution environment providing as much detail as possible
4747+ render: Markdown
4848+ validations:
4949+ required: false
5050+5151+ - type: textarea
5252+ attributes:
5353+ label: Anything else?
5454+ description: |
5555+ Links? References? Anything that will give us more context about the issue you are encountering!
5656+5757+ Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.
5858+ validations:
5959+ required: false
+41
.github/ISSUE_TEMPLATE/feature_request.yml
···11+name: 🚀 Feature Request
22+description: Request a new feature or enhancement
33+title: "<title>"
44+labels:
55+ - enhancement
66+body:
77+ - type: checkboxes
88+ attributes:
99+ label: Is there an existing issue for this?
1010+ description: Please search to see if an issue already exists for the feature you want.
1111+ options:
1212+ - label: I have searched the existing issues
1313+ required: true
1414+1515+ - type: textarea
1616+ attributes:
1717+ label: How would this feature be useful?
1818+ description: Describe any use cases this solves or frustrations it alleviates.
1919+ validations:
2020+ required: false
2121+2222+ - type: textarea
2323+ attributes:
2424+ label: Describe the solution you'd like
2525+ description: If you have an idea on how to do this, let us know here!
2626+ validations:
2727+ required: false
2828+2929+ - type: textarea
3030+ attributes:
3131+ label: Describe alternatives you've considered
3232+ description: If there's some workaround or alternative solutions, let us know here!
3333+ validations:
3434+ required: false
3535+3636+ - type: textarea
3737+ attributes:
3838+ label: Anything else?
3939+ description: Any other relevant information or background.
4040+ validations:
4141+ required: false
+28
.github/ISSUE_TEMPLATE/question.yml
···11+name: ❓ Question
22+description: Ask something about the project
33+title: "<title>"
44+labels:
55+ - question
66+body:
77+ - type: checkboxes
88+ attributes:
99+ label: Is there an existing issue for this?
1010+ description: Please search to see if an issue already exists for the question you want to ask.
1111+ options:
1212+ - label: I have searched the existing issues
1313+ required: true
1414+1515+ - type: textarea
1616+ attributes:
1717+ label: Description
1818+ description: Ask your question here.
1919+ placeholder: How can I...? Is it possible to...?
2020+ validations:
2121+ required: false
2222+2323+ - type: textarea
2424+ attributes:
2525+ label: Anything else?
2626+ description: Any other relevant information or background.
2727+ validations:
2828+ required: false