GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - issue9/cmdopt: cmdopt

BranchesTags
Open more actions menu

Latest commit

 

History

82 Commits
82 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
cmdopt.go
cmdopt.go
 
 
cmdopt_test.go
cmdopt_test.go
 
 
command.go
command.go
 
 
command_test.go
command_test.go
 
 
go.mod
go.mod
 
 
go.sum
go.sum
 
 
help.go
help.go
 
 

Repository files navigation

cmdopt Go license codecov PkgGoDev Go version

cmdopt 命令行选项的增强,可以轻松处理子命令。复用 flag 包。

opt := cmdopt.New(...)

// 子命令 build,为一个 flag.FlagSet 实例
build := opt.New("build", "title", "usage", func(f *flag.FlagSet) DoFunc {
    v := f.Bool("v", "false", ...)

    return func(output io.Writer)error{
        if v {
            ...
        } else {
            output.Write([]byte("build"))
        }
    }
})

// 子命令 install
install := opt.New("install", "title", "usage", func(*flag.FlagSet) DoFunc {
    return func(output io.Writer)error{
        output.Write([]byte("install"))
    }
})

版权

本项目采用 MIT 开源授权许可证,完整的授权说明可在 LICENSE 文件中找到。

About

cmdopt

pkg.go.dev/github.com/issue9/cmdopt

Topics

command

Resources

Readme
MIT license
Activity
Custom properties

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.