Skip to content

Commit

Permalink
update readme and some gh script
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Oct 11, 2021
1 parent 9817bde commit a76759b
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 75 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ on:
jobs:

test:
name: Test on go ${{ matrix.go_version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
name: Test on go ${{ matrix.go_version }}
runs-on: ubuntu-latest
strategy:
matrix:
go_version: [1.13, 1.14, 1.15, 1.16]
os: [ubuntu-latest, windows-latest, macOS-latest]
go_version: [1.13, 1.14, 1.15, 1.16, 1.17]

steps:
- name: Check out code into the Go module directory
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: true
matrix:
go: [1.15]
go: [1.16]

steps:
- name: Checkout
Expand Down
78 changes: 21 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
[![Go Report Card](https://goreportcard.com/badge/github.com/gookit/gcli)](https://goreportcard.com/report/github.com/gookit/gcli)
[![Coverage Status](https://coveralls.io/repos/github/gookit/gcli/badge.svg?branch=master)](https://coveralls.io/github/gookit/gcli?branch=master)

A simple-to-use command line application, written using golang.
A simple and easy-to-use command-line application and tool library written in Golang.
Including running commands, color styles, data display, progress display, interactive methods, etc.

## [中文说明](README.zh-CN.md)

Expand Down Expand Up @@ -109,9 +110,11 @@ func main() {

## Binding flags

flags parse and manage by `gflag`, allow binding flag options and arguments.
flags binding and manage by builtin `gflag.go`, allow binding flag options and arguments.

### Bind Options
### Bind options

gcli support multi method to binding flag options.

#### Use flag methods

Expand Down Expand Up @@ -194,7 +197,7 @@ func main() {
}
```

### Bind Arguments
### Bind arguments

**About arguments**:

Expand Down Expand Up @@ -229,12 +232,7 @@ cmd.Arg("arg0", gcli.Argument{
Desc: "the first argument, is required",
Require: true,
})
cmd.BindArg("arg0", gcli.Argument{
Name: "ag0",
Desc: "the second argument, is required",
Require: true,
})
cmd.Arg("arg2", gcli.Argument{
cmd.BindArg("arg2", gcli.Argument{
Name: "ag0",
Desc: "the third argument, is is optional",
})
Expand Down Expand Up @@ -298,15 +296,15 @@ app.Add(&gcli.Command{
Build the example application as demo

```bash
% go build ./_examples/cliapp
$ go build ./_examples/cliapp
```

**Display version**

```bash
% ./cliapp --version
$ ./cliapp --version
# or use -V
% ./cliapp -V
$ ./cliapp -V
```

![app-version](_examples/images/app-version.jpg)
Expand Down Expand Up @@ -337,7 +335,7 @@ Format:
Run example:

```bash
% ./cliapp example -c some.txt -d ./dir --id 34 -n tom -n john val0 val1 val2 arrVal0 arrVal1 arrVal2
$ ./cliapp example -c some.txt -d ./dir --id 34 -n tom -n john val0 val1 val2 arrVal0 arrVal1 arrVal2
```

You can see:
Expand Down Expand Up @@ -368,8 +366,8 @@ import "github.com/gookit/gcli/v3/builtin"
Build and run command(_This command can be deleted after success._):

```bash
% go build ./_examples/cliapp.go && ./cliapp genac -h // display help
% go build ./_examples/cliapp.go && ./cliapp genac // run gen command
$ go build ./_examples/cliapp.go && ./cliapp genac -h // display help
$ go build ./_examples/cliapp.go && ./cliapp genac // run gen command
```

will see:
Expand Down Expand Up @@ -431,7 +429,7 @@ var MyCmd = &gcli.Command{
> the source file at: [example.go](_examples/cmd/example.go)
```go
package cmd
package main

import (
"fmt"
Expand Down Expand Up @@ -459,8 +457,9 @@ var ExampleCommand = &gcli.Command{
Examples: `{$binName} {$cmd} --id 12 -c val ag0 ag1
<cyan>{$fullCmd} --names tom --names john -n c</> test use special option`,
Config: func(c *gcli.Command) {
// 绑定命令选项信息
c.IntOpt(&exampleOpts.id, "id", "", 2, "the id option")
// binding options
// ...
c.IntOpt(&exampleOpts.id, "id", "", 2, "the id option")
c.StrOpt(&exampleOpts.c, "config", "c", "value", "the config option")
// notice `DIRECTORY` will replace to option value type
c.StrOpt(&exampleOpts.dir, "dir", "d", "", "the `DIRECTORY` option")
Expand All @@ -469,11 +468,9 @@ var ExampleCommand = &gcli.Command{
// 支持绑定自定义变量, 但必须实现 flag.Value 接口
c.VarOpt(&exampleOpts.names, "names", "n", "the option message")

// 绑定命令参数信息,按参数位置绑定
// binding arguments
c.AddArg("arg0", "the first argument, is required", true)
c.AddArg("arg1", "the second argument, is required", true)
c.AddArg("arg2", "the optional argument, is optional")
c.AddArg("arrArg", "the array argument, is array", false, true)
// ...
},
Func: exampleExecute,
}
Expand Down Expand Up @@ -699,7 +696,7 @@ color.Comment.Println("your input password is: ", pwd)

![colored-demo](_examples/images/color/color-demo.jpg)

### Usage
### Color usage

```go
package main
Expand Down Expand Up @@ -743,39 +740,6 @@ func main() {
}
```

### More usage

- Basic color

```go
color.Bold.Println("bold message")
color.Yellow.Println("yellow message")
```

- Extra themes

```go
color.Info.Println("Info message")
color.Danger.Println("Danger message")
color.Error.Println("Error message")
color.Success.Println("Success message")
```

- Use like html tag

> **Support** working on windows `cmd.exe` `powerShell`
```go
// use style tag
color.Print("<suc>he</><comment>llo</>, <cyan>wel</><red>come</>")
color.Println("<suc>hello</>")
color.Println("<error>hello</>")
color.Println("<warning>hello</>")

// custom color attributes
color.Print("<fg=yellow;bg=black;op=underscore;>hello, welcome</>\n")
```

> **For more information on the use of color libraries, please visit [gookit/color](https://github.com/gookit/color)**
## Gookit packages
Expand Down
13 changes: 4 additions & 9 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[![Go Report Card](https://goreportcard.com/badge/github.com/gookit/gcli)](https://goreportcard.com/report/github.com/gookit/gcli)
[![Coverage Status](https://coveralls.io/repos/github/gookit/gcli/badge.svg?branch=master)](https://coveralls.io/github/gookit/gcli?branch=master)

一个Golang下的简单易用的命令行应用,工具库。包含运行命令,颜色风格,数据展示,进度显示,交互方法等
Golang编写的简单易用的命令行应用,工具库。包含运行命令,颜色风格,数据展示,进度显示,交互方法等

## [ENGLISH](README.md)

Expand Down Expand Up @@ -58,7 +58,7 @@ go get github.com/gookit/gcli/v3

如下,引入当前包就可以快速的编写cli应用了

```go
```go
package main

import (
Expand Down Expand Up @@ -88,7 +88,7 @@ func main() {

// .... add more ...

app.Run()
app.Run(nil)
}
```

Expand Down Expand Up @@ -381,12 +381,7 @@ cmd.Add("arg0", gcli.Argument{
Desc: "the first argument, is required",
Require: true,
})
cmd.BindArg("arg0", gcli.Argument{
Name: "ag0",
Desc: "the second argument, is required",
Require: true,
})
cmd.Add("arg2", gcli.Argument{
cmd.BindArg("arg2", gcli.Argument{
Name: "ag0",
Desc: "the third argument, is is optional",
})
Expand Down
4 changes: 2 additions & 2 deletions builtin/gen_emoji_codeMap.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type Gemoji struct {

var gem = &genEmojiMap{}

// GenEmojiMapCommand create
// GenEmojiMap create
var GenEmojiMap = &gcli.Command{
Name: "gen-emojis",
Aliases: []string{"gen-emj"},
Expand Down Expand Up @@ -89,7 +89,7 @@ func (g *genEmojiMap) Download(remoteFile string, saveAs string) error {
const templateString = `
package {{.PkgName}}
// NOTE: THIS FILE WAS PRODUCED BY THE
// EMOJI COD EMAP CODE GENERATION TOOL (https://github.com/gookit/gcli)
// EMOJI CODE MAP CODE GENERATION TOOL (https://github.com/gookit/gcli)
// DO NOT EDIT
// Mapping from character to concrete escape code.
var emojiMap = map[string]string{
Expand Down
2 changes: 2 additions & 0 deletions docs/guide/chapter-01.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# chapter

2 changes: 1 addition & 1 deletion resource/Changelog-TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## TODO

- [ ] flag option support alias name.
- [x] flag option support alias name.
- It isn't shorts name. eg: `name='dry-run' alias='dr'`
- [ ] support flag option category
- [ ] support command category by `c.Category`
Expand Down
2 changes: 1 addition & 1 deletion resource/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
################################################################################
### builder image
################################################################################
FROM golang:1.14-alpine as Builder
FROM golang:1.16-alpine as Builder

# Recompile the standard library without CGO
#RUN CGO_ENABLED=0 go install -a std
Expand Down

0 comments on commit a76759b

Please sign in to comment.