Skip to content

Commit

Permalink
Merge pull request #52 from tamada/issue/completion_script
Browse files Browse the repository at this point in the history
Issue/completion script
  • Loading branch information
tamada committed Apr 18, 2019
2 parents ffa7ec8 + b970c66 commit 2ac4a93
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
6 changes: 2 additions & 4 deletions completions/rrh_completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ __rrh_groups(){

__rrh_repositories(){
rrh repository list --id
# rrh list --only-repositoryname
}

__rrh_group_repo_forms(){
rrh repository list --group
# rrh list --group-repository-form
rrh repository list --with-group
}

__rrh_add() {
Expand Down Expand Up @@ -42,7 +40,7 @@ __rrh_config(){
if [ "$4" = "$2" ]; then
COMPREPLY=($(compgen -W "unset set list" -- $1))
elif [ "$2" = "set" ] || [ "$2" = "unset" ]; then
COMPREPLY=($(compgen -W rrhenvs $1))
COMPREPLY=($(compgen -W "$rrhenvs" -- $1))
elif [ "$2" = "RRH_ON_ERROR" ] && [ "${COMP_WORDS[2]}" = "set" ]; then
COMPREPLY=($(compgen -W "IGNORE WARN FAIL FAIL_IMMEDIATELY" -- $1))
elif [ "$2" = "RRH_AUTO_CREATE_GROUP" -o "$2" = "RRH_AUTO_DELETE_GROUP" -o "$2" = "RRH_SORT_ON_UPDATING" -o "$2" = "RRH_ENABLE_COLORIZED" ] && [ "${COMP_WORDS[2]}" = "set" ]; then
Expand Down
8 changes: 4 additions & 4 deletions repository/repository_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ func (list *listCommand) buildFlagSet() (*flag.FlagSet, *listOptions) {
flags := flag.NewFlagSet("list", flag.ContinueOnError)
flags.Usage = func() { fmt.Println(list.Help()) }
flags.BoolVar(&options.id, "id", false, "prints id of the repository.")
flags.BoolVar(&options.group, "group", false, "prints group of the repository.")
flags.BoolVar(&options.path, "path", false, "prints path of the repository.")
flags.BoolVar(&options.group, "with-group", false, "prints group of the repository.")
return flags, &options
}

Expand Down Expand Up @@ -311,9 +311,9 @@ ARGUMENTS
func (list *listCommand) Help() string {
return `rrh repository list [OPTIONS] [ARGUMENTS...]
OPTIONS
-i, --id prints ids in the results.
-p, --path prints paths in the results.
-g, --group prints the results in "GROUP/REPOSITORY" format.
--id prints ids in the results.
--path prints paths in the results.
--with-group prints the results in "GROUP/REPOSITORY" format.
Note:
This sub command is used for a completion target generation.`
}
Expand Down
12 changes: 6 additions & 6 deletions repository/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestRepository(t *testing.T) {
{[]string{"list"}, 0, "", false},
{[]string{"list", "--id"}, 0, "repo1+repo2", false},
{[]string{"list", "--path", "repo2"}, 0, "path2", false},
{[]string{"list", "--group", "repo1"}, 0, "group1/repo1", false},
{[]string{"list", "--with-group", "repo1"}, 0, "group1/repo1", false},
}
for _, tc := range testcases {
var dbFile = common.Rollback("../testdata/tmp.json", "../testdata/config.json", func() {
Expand Down Expand Up @@ -52,10 +52,10 @@ func TestListRepository(t *testing.T) {
}{
{[]string{"--id"}, 0, "repo1+repo2", false},
{[]string{"--path"}, 0, "path1+path2", false},
{[]string{"--group"}, 0, "group1/repo1+group3/repo2", false},
{[]string{"--with-group"}, 0, "group1/repo1+group3/repo2", false},
{[]string{"--id", "repo2"}, 0, "repo2", false},
{[]string{"--path", "repo1"}, 0, "path1", false},
{[]string{"--group", "repo2"}, 0, "group3/repo2", false},
{[]string{"--with-group", "repo2"}, 0, "group3/repo2", false},
{[]string{}, 0, "", false},
{[]string{"--invalid-option"}, 1, "", true},
}
Expand Down Expand Up @@ -177,9 +177,9 @@ ARGUMENTS

var listCommandHelp = `rrh repository list [OPTIONS] [ARGUMENTS...]
OPTIONS
-i, --id prints ids in the results.
-p, --path prints paths in the results.
-g, --group prints the results in "GROUP/REPOSITORY" format.
--id prints ids in the results.
--path prints paths in the results.
--with-group prints the results in "GROUP/REPOSITORY" format.
Note:
This sub command is used for a completion target generation.`

Expand Down

0 comments on commit 2ac4a93

Please sign in to comment.