Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A simple, fast, and fun package for building command line apps in Go

License

NotificationsYou must be signed in to change notification settings

aperturerobotics/cli

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Run TestsGo ReferenceGo Report Cardcodecov

aperturerobotics/cli is afork of the popularurfave/cli v2 package for building command line apps in Go. The goal is to enable developers to write fast and distributable command line applications in an expressive way, while minimizing dependencies and maximizing compatibility.

Key differences fromurfave/cli:

  1. Slim and Reflection-Free:
    • Removedreflect usage for smaller binaries and better performance.
    • Tinygo compatible.
    • Removed documentation generators.
    • Removed altsrc package to focus on CLI handling only.
  2. Stability: Try to maintain backward compatibility as much as possible.

Installation

Using this package requires a working Go environment.See the install instructions for Go.

Go Modules are required when using this package.See the go blog guide on using Go Modules.

go get github.com/aperturerobotics/cli

Getting Started

Here's a simple example to get you started:

package mainimport ("fmt""log""os""github.com/aperturerobotics/cli")funcmain() {app:=&cli.App{Name:"greet",Usage:"a simple greeter application",Flags: []cli.Flag{&cli.StringFlag{Name:"name",Value:"world",Usage:"who to greet",EnvVars: []string{"GREET_NAME"},},},// The action for the root command (optional)Action:func(ctx*cli.Context)error {name:=ctx.String("name")fmt.Printf("Hello %s!\n",name)returnnil},// Define subcommandsCommands: []*cli.Command{{Name:"add",Usage:"add a task to the list",// Action for the 'add' subcommandAction:func(ctx*cli.Context)error {fmt.Println("added task: ",ctx.Args().First())returnnil},},{Name:"complete",Usage:"complete a task on the list",// Action for the 'complete' subcommandAction:func(ctx*cli.Context)error {fmt.Println("completed task: ",ctx.Args().First())returnnil},},},}// Run the applicationiferr:=app.Run(os.Args);err!=nil {log.Fatal(err)}}// Try running this:// GREET_NAME=everyone ./greet --name someone add some-task// ./greet complete --help

Running this provides basic command functionality, including help text generation, flag parsing, environment variable handling, and subcommand routing. You can easily add more flags, subcommands, and complex actions.

Documentation

Full documentation and examples are available in the./docs directory and online athttps://cli.aperture.app.

License

This fork retains the original MIT license fromurfave/cli. SeeLICENSE.

About

A simple, fast, and fun package for building command line apps in Go

Resources

License

Code of conduct

Stars

Watchers

Forks

Languages

  • Go99.4%
  • Other0.6%

[8]ページ先頭

©2009-2025 Movatter.jp