Skip to content

Commit

Permalink
chore: update readme and update some method comments
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Jul 27, 2022
1 parent 0231311 commit 517b05e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/gookit/gcli?style=flat-square)
[![Actions Status](https://github.com/gookit/gcli/workflows/action-tests/badge.svg)](https://github.com/gookit/gcli/actions)
[![GitHub tag (latest SemVer)](https://img.shields.io/github/tag/gookit/gcli)](https://github.com/gookit/gcli)
[![Build Status](https://travis-ci.org/gookit/gcli.svg?branch=master)](https://travis-ci.org/gookit/gcli)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/60c587f0491748fcabc1b3fe08d98074)](https://app.codacy.com/app/inhere/gcli?utm_source=github.com&utm_medium=referral&utm_content=gookit/gcli&utm_campaign=Badge_Grade_Dashboard)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/4f071e6858fb4117b6c1376c9316d8ef)](https://www.codacy.com/gh/gookit/gcli/dashboard?utm_source=github.com&utm_medium=referral&utm_content=gookit/gcli&utm_campaign=Badge_Grade)
[![GoDoc](https://godoc.org/github.com/gookit/gcli?status.svg)](https://pkg.go.dev/github.com/gookit/gcli/v3)
[![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)
Expand Down
3 changes: 1 addition & 2 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/gookit/gcli?style=flat-square)
[![Actions Status](https://github.com/gookit/gcli/workflows/action-tests/badge.svg)](https://github.com/gookit/gcli/actions)
[![GitHub tag (latest SemVer)](https://img.shields.io/github/tag/gookit/gcli)](https://github.com/gookit/gcli)
[![Build Status](https://travis-ci.org/gookit/gcli.svg?branch=master)](https://travis-ci.org/gookit/gcli)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/60c587f0491748fcabc1b3fe08d98074)](https://app.codacy.com/app/inhere/gcli?utm_source=github.com&utm_medium=referral&utm_content=gookit/gcli&utm_campaign=Badge_Grade_Dashboard)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/4f071e6858fb4117b6c1376c9316d8ef)](https://www.codacy.com/gh/gookit/gcli/dashboard?utm_source=github.com&utm_medium=referral&utm_content=gookit/gcli&utm_campaign=Badge_Grade)
[![GoDoc](https://godoc.org/github.com/gookit/gcli?status.svg)](https://pkg.go.dev/github.com/gookit/gcli/v3)
[![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)
Expand Down
4 changes: 4 additions & 0 deletions interact/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,7 @@ Preview:

![](images/select.png)

## Refers

- https://github.com/manifoldco/promptui
- https://github.com/chzyer/readline
5 changes: 3 additions & 2 deletions interact/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ func (v Value) IsEmpty() bool {

// SelectResult data store
type SelectResult struct {
Value // V the select value(s)
K Value // K the select key(s)
Value // V the select value(s)
// K the select key(s)
K Value
}

// create SelectResult create
Expand Down
3 changes: 3 additions & 0 deletions interact/interact.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func Unconfirmed(message string, defVal ...bool) bool {
}

// Ask a question and return the result of the input.
//
// Usage:
// answer := Ask("Your name?", "", nil)
// answer := Ask("Your name?", "tom", nil)
Expand Down Expand Up @@ -60,12 +61,14 @@ func SingleSelect(title string, options interface{}, defOpt string, allowQuit ..
}

// SelectOne select one of the options, returns selected option value
//
// map options:
// {
// // option value => option name
// 'a' => 'chengdu',
// 'b' => 'beijing'
// }
//
// array options:
// {
// // only name, value will use index
Expand Down
12 changes: 3 additions & 9 deletions interact/select.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strings"

"github.com/gookit/color"
"github.com/gookit/goutil/arrutil"
"github.com/gookit/goutil/strutil"
)

Expand All @@ -33,6 +34,7 @@ type Select struct {
}

// NewSelect instance.
//
// Usage:
// s := NewSelect("Your city?", []string{"chengdu", "beijing"})
// r := s.Run()
Expand Down Expand Up @@ -99,14 +101,7 @@ func (s *Select) prepare() (keys []string) {
// format some field data
s.DefOpt = strings.TrimSpace(s.DefOpt)
if len(s.DefOpts) > 0 {
var ss []string
for _, v := range s.DefOpts {
if v = strings.TrimSpace(v); v != "" {
ss = append(ss, v)
}
}

s.DefOpts = ss
s.DefOpts = arrutil.StringsFilter(s.DefOpts)
}
return
}
Expand Down Expand Up @@ -251,6 +246,5 @@ func (s *Select) Run() *SelectResult {
if s.MultiSelect {
return s.selectMulti()
}

return s.selectOne()
}

0 comments on commit 517b05e

Please sign in to comment.