Skip to content

Commit

Permalink
Merge 4b8ab57 into fa1627d
Browse files Browse the repository at this point in the history
  • Loading branch information
tamada committed Dec 18, 2019
2 parents fa1627d + 4b8ab57 commit cec5da2
Show file tree
Hide file tree
Showing 23 changed files with 739 additions and 82 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GO=go
NAME := rrh
VERSION := 1.0.4
VERSION := 1.1.0
REVISION := $(shell git rev-parse --short HEAD)

all: test build
Expand Down
44 changes: 43 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![codebeat badge](https://codebeat.co/badges/15e04551-d448-4ad3-be1d-e98b1e586f1a)](https://codebeat.co/projects/github-com-tamada-rrh-master)
[![go report](https://goreportcard.com/badge/github.com/tamada/rrh)](https://goreportcard.com/report/github.com/tamada/rrh)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://github.com/tamada/rrh/blob/master/LICENSE)
[![Version](https://img.shields.io/badge/Version-1.0.4-yellowgreen.svg)](https://github.com/tamada/rrh/releases/tag/v1.0.4)
[![Version](https://img.shields.io/badge/Version-1.1.0-yellowgreen.svg)](https://github.com/tamada/rrh/releases/tag/v1.1.0)

# RRH

Expand Down Expand Up @@ -207,6 +207,7 @@ If sub-sub-command was not specified, it runs `list` sub-sub-command.
rrh group <SUBCOMMAND>
SUBCOMMAND
add add new group.
info show information of specified groups.
list list groups (default).
of shows groups of the specified repository.
rm remove group.
Expand All @@ -226,6 +227,16 @@ ARGUMENTS
GROUPS gives group names.
```
##### `rrh group info`
Show information of specified groups.
```sh
rrh group info <GROUPS...>
ARGUMENTS
GROUPS group names to show the information.
```
##### `rrh group list`
Displays group list.
Expand Down Expand Up @@ -352,6 +363,7 @@ rrh repository <SUBCOMMAND>
SUBCOMMAND
info [OPTIONS] <REPO...> shows repository information.
update [OPTIONS] <REPO...> updates repository information.
update-remotes [OPTIONS] update all remote entries.
```
##### `rrh repository info`
Expand Down Expand Up @@ -381,6 +393,17 @@ ARGUMENTS
REPOSITORY specifies the repository id.
```
##### `rrh repository update-remotes`
update remote entries in the all repositories.
```sh
rrh repository update-remotes [OPTIONS]
OPTIONS
-d, --dry-run dry-run mode.
-v, --verbose verbose mode.
```
#### `rrh rm`
Removes the specified groups, repositories, and relations.
Expand Down Expand Up @@ -651,6 +674,24 @@ RRH means "Repositories, Ready to Hack," is not the abbreviation of the Red Ridi
![icon of rrh](https://raw.githubusercontent.com/tamada/rrh/master/docs/static/favicon-64x64.png) by [iconpon.com](https://www.iconpon.com/)
### Version histories
* [v1.1.0](https://github.com/tamada/rrh/releases/tag/v1.1.0) (18 Dec, 2018)
* [\#79](https://github.com/tamada/rrh/issues/79) (add `rrh group info` sub command)
* [\#77](https://github.com/tamada/rrh/issues/77) (introduce `rrh repository update-remotes` sub command)
* [\#81](https://github.com/tamada/rrh/issues/81) (introduce options for `rrh prune` command)
* [v1.0.4](https://github.com/tamada/rrh/releases/tag/v1.1.0) (13 Jul, 2018)
* [\#74](https://github.com/tamada/rrh/issues/74) (permission of created README.md by rrh-new was invalid (204))
* [\#75](https://github.com/tamada/rrh/issues/75) (Introduce `--dry-run` option to `rrh new` command)
* [v1.0.3](https://github.com/tamada/rrh/releases/tag/v1.1.0) (29 Jun, 2018)
* [\#72](https://github.com/tamada/rrh/issues/72) (Print belonging groups on `rrh repository info`)
* [v1.0.2](https://github.com/tamada/rrh/releases/tag/v1.1.0) (29 Jun, 2018)
* [\#67](https://github.com/tamada/rrh/issues/67) (implements `rrh new` sub command)
* [v1.0.1](https://github.com/tamada/rrh/releases/tag/v1.1.0) (26 Jun, 2018)
* [\#68](https://github.com/tamada/rrh/issues/68) (`rrh group` prints `rrh config list`)
* [v1.0.0](https://github.com/tamada/rrh/releases/tag/v1.1.0) (18 Jun, 2018)
* The first public release.
## Table of Contents
* [Description](#description)
Expand Down Expand Up @@ -692,3 +733,4 @@ RRH means "Repositories, Ready to Hack," is not the abbreviation of the Red Ridi
* [Author](#author)
* [Why the project name RRH?](#why-the-project-name-rrh)
* [Attributions](#attributions)
* [Version histories](#version-histories)
8 changes: 8 additions & 0 deletions completions/bash/rrh
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ __rrh_group_of() {
COMPREPLY=($(compgen -W "$repos" -- "${cur}"))
}

__rrh_group_info() {
groups="$(__rrh_groups)"
COMPREPLY=($(compgen -W "$groups" -- "${cur}"))
}

__rrh_group_update() {
if [[ "$1" =~ ^\- ]]; then
COMPREPLY=($(compgen -W "-n --name -d --desc -o --omit-list" -- "${cur}"))
Expand All @@ -127,6 +132,9 @@ __rrh_group() {
add)
__rrh_group_add "$1" "$2" "$3" "$4" "$subsub"
;;
info)
__rrh_group_info "$1" "$2" "$3" "$4" "$subsub"
;;
list)
__rrh_group_list "$1" "$2" "$3" "$4" "$subsub"
;;
Expand Down
3 changes: 2 additions & 1 deletion docs/content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ title: RRH
[![codebeat badge](https://codebeat.co/badges/15e04551-d448-4ad3-be1d-e98b1e586f1a)](https://codebeat.co/projects/github-com-tamada-rrh-master)
[![go report](https://goreportcard.com/badge/github.com/tamada/rrh)](https://goreportcard.com/report/github.com/tamada/rrh)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://github.com/tamada/rrh/blob/master/LICENSE)
[![Version](https://img.shields.io/badge/Version-1.0.4-yellowgreen.svg)](https://github.com/tamada/rrh/releases/tag/v1.0.4)
[![Version](https://img.shields.io/badge/Version-1.1.0-yellowgreen.svg)](https://github.com/tamada/rrh/releases/tag/v1.1.0)

RRH is a simple git repository manager.

Expand Down Expand Up @@ -36,3 +36,4 @@ RRH is a simple git repository manager.
* [Authors](about#authors)
* [Why the project name RRH](about#why-the-project-name-rrh)
* [Attributions](about#attributions)
* [Version histories](about#version-histories)
18 changes: 18 additions & 0 deletions docs/content/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,21 @@ RRH means "Repositories, Ready to Hack," is not the abbreviation of the Red Ridi
#### Icon of RRH

{{< figure src="/rrh/images/logo.png" width="64" >}} by [iconpon.com](https://www.iconpon.com/)

### Version histories

* [v1.1.0](https://github.com/tamada/rrh/releases/tag/v1.1.0) (18 Dec, 2018)
* [\#79](https://github.com/tamada/rrh/issues/79) (add `rrh group info` sub command)
* [\#77](https://github.com/tamada/rrh/issues/77) (introduce `rrh repository update-remotes` sub command)
* [\#81](https://github.com/tamada/rrh/issues/81) (introduce options for `rrh prune` command)
* [v1.0.4](https://github.com/tamada/rrh/releases/tag/v1.0.4) (13 Jul, 2018)
* [\#74](https://github.com/tamada/rrh/issues/74) (permission of created README.md by rrh-new was invalid (204))
* [\#75](https://github.com/tamada/rrh/issues/75) (Introduce `--dry-run` option to `rrh new` command)
* [v1.0.3](https://github.com/tamada/rrh/releases/tag/v1.0.3) (29 Jun, 2018)
* [\#72](https://github.com/tamada/rrh/issues/72) (Print belonging groups on `rrh repository info`)
* [v1.0.2](https://github.com/tamada/rrh/releases/tag/v1.0.2) (29 Jun, 2018)
* [\#67](https://github.com/tamada/rrh/issues/67) (implements `rrh new` sub command)
* [v1.0.1](https://github.com/tamada/rrh/releases/tag/v1.0.1) (26 Jun, 2018)
* [\#68](https://github.com/tamada/rrh/issues/68) (`rrh group` prints `rrh config list`)
* [v1.0.0](https://github.com/tamada/rrh/releases/tag/v1.0.0) (18 Jun, 2018)
* The first public release.
27 changes: 26 additions & 1 deletion docs/content/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ If sub-sub-command was not specified, it runs `list` sub-sub-command.
rrh group <SUBCOMMAND>
SUBCOMMAND
add add new group.
info show information of specified groups.
list list groups (default).
of shows groups of the specified repository.
rm remove group.
Expand All @@ -156,6 +157,16 @@ ARGUMENTS
GROUPS gives group names.
```
##### `rrh group info`
Show information of specified groups.
```sh
rrh group info <GROUPS...>
ARGUMENTS
GROUPS group names to show the information.
```
##### `rrh group list`
Displays group list.
Expand Down Expand Up @@ -261,7 +272,10 @@ The unnecessary repositories are to have an invalid path.
```sh
rrh prune
rrh prune [OPTIONS]
OPTIONS
-d, --dry-run dry-run mode.
-v, --verbose verbose mode.
```
#### `rrh repository`
Expand All @@ -273,6 +287,7 @@ rrh repository <SUBCOMMAND>
SUBCOMMAND
info [OPTIONS] <REPO...> shows repository information.
update [OPTIONS] <REPO...> updates repository information.
update-remotes [OPTIONS] update all remote entries.
```
##### `rrh repository info`
Expand Down Expand Up @@ -302,6 +317,16 @@ ARGUMENTS
REPOSITORY specifies the repository id.
```
##### `rrh repository update-remotes`
update remote entries in the all repositories.
```sh
rrh repository update-remotes [OPTIONS]
OPTIONS
-d, --dry-run dry-run mode.
-v, --verbose verbose mode.
```
#### `rrh rm`
Expand Down
7 changes: 7 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.12
require (
github.com/armon/go-radix v1.0.0
github.com/bgentry/speakeasy v0.1.0
github.com/cheggaaa/pb v2.0.7+incompatible
github.com/dustin/go-humanize v1.0.0
github.com/emirpasic/gods v1.12.0
github.com/fatih/color v1.7.0
Expand All @@ -28,6 +29,12 @@ require (
golang.org/x/net v0.0.0-20190520210107-018c4d40a106
golang.org/x/sys v0.0.0-20190522044717-8097e1b27ff5
golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59 // indirect
gopkg.in/VividCortex/ewma.v1 v1.1.1 // indirect
gopkg.in/cheggaaa/pb.v2 v2.0.7 // indirect
gopkg.in/fatih/color.v1 v1.7.0 // indirect
gopkg.in/mattn/go-colorable.v0 v0.1.0 // indirect
gopkg.in/mattn/go-isatty.v0 v0.0.4 // indirect
gopkg.in/mattn/go-runewidth.v0 v0.0.4 // indirect
gopkg.in/src-d/go-billy.v4 v4.3.0
gopkg.in/src-d/go-git.v4 v4.11.0
gopkg.in/warnings.v0 v0.1.2
Expand Down
14 changes: 14 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI=
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/cheggaaa/pb v2.0.7+incompatible h1:gLKifR1UkZ/kLkda5gC0K6c8g+jU2sINPtBeOiNlMhU=
github.com/cheggaaa/pb v2.0.7+incompatible/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
Expand Down Expand Up @@ -89,7 +91,19 @@ golang.org/x/tools v0.0.0-20190612232758-d4e310b4a8a5 h1:WfRBLVK37R+k1gUOKuZX8Jt
golang.org/x/tools v0.0.0-20190612232758-d4e310b4a8a5/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59 h1:QjA/9ArTfVTLfEhClDCG7SGrZkZixxWpwNCDiwJfh88=
golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
gopkg.in/VividCortex/ewma.v1 v1.1.1 h1:tWHEKkKq802K/JT9RiqGCBU5fW3raAPnJGTE9ostZvg=
gopkg.in/VividCortex/ewma.v1 v1.1.1/go.mod h1:TekXuFipeiHWiAlO1+wSS23vTcyFau5u3rxXUSXj710=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/cheggaaa/pb.v2 v2.0.7 h1:beaAg8eacCdMQS9Y7obFEtkY7gQl0uZ6Zayb3ry41VY=
gopkg.in/cheggaaa/pb.v2 v2.0.7/go.mod h1:0CiZ1p8pvtxBlQpLXkHuUTpdJ1shm3OqCF1QugkjHL4=
gopkg.in/fatih/color.v1 v1.7.0 h1:bYGjb+HezBM6j/QmgBfgm1adxHpzzrss6bj4r9ROppk=
gopkg.in/fatih/color.v1 v1.7.0/go.mod h1:P7yosIhqIl/sX8J8UypY5M+dDpD2KmyfP5IRs5v/fo0=
gopkg.in/mattn/go-colorable.v0 v0.1.0 h1:WYuADWvfvYC07fm8ygYB3LMcsc5CunpxfMGKawHkAos=
gopkg.in/mattn/go-colorable.v0 v0.1.0/go.mod h1:BVJlBXzARQxdi3nZo6f6bnl5yR20/tOL6p+V0KejgSY=
gopkg.in/mattn/go-isatty.v0 v0.0.4 h1:NtS1rQGQr4IaFWBGz4Cz4BhB///gyys4gDVtKA7hIsc=
gopkg.in/mattn/go-isatty.v0 v0.0.4/go.mod h1:wt691ab7g0X4ilKZNmMII3egK0bTxl37fEn/Fwbd8gc=
gopkg.in/mattn/go-runewidth.v0 v0.0.4 h1:r0P71TnzQDlNIcizCqvPSSANoFa3WVGtcNJf3TWurcY=
gopkg.in/mattn/go-runewidth.v0 v0.0.4/go.mod h1:BmXejnxvhwdaATwiJbB1vZ2dtXkQKZGu9yLFCZb4msQ=
gopkg.in/src-d/go-billy.v4 v4.2.1/go.mod h1:tm33zBoOwxjYHZIE+OV8bxTWFMJLrconzFMd38aARFk=
gopkg.in/src-d/go-billy.v4 v4.3.0 h1:KtlZ4c1OWbIs4jCv5ZXrTqG8EQocr0g/d4DjNg70aek=
gopkg.in/src-d/go-billy.v4 v4.3.0/go.mod h1:tm33zBoOwxjYHZIE+OV8bxTWFMJLrconzFMd38aARFk=
Expand Down
57 changes: 57 additions & 0 deletions internal/group_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ type groupUpdateCommand struct{}
type groupRemoveCommand struct {
options *groupRemoveOptions
}
type groupInfoCommand struct {
}

/*
GroupCommandFactory returns an instance of command.
Expand All @@ -30,6 +32,10 @@ func GroupCommandFactory() (cli.Command, error) {
return &GroupCommand{}, nil
}

func groupInfoCommandFactory() (cli.Command, error) {
return &groupInfoCommand{}, nil
}

func groupAddCommandFactory() (cli.Command, error) {
return &groupAddCommand{&groupAddOptions{}}, nil
}
Expand Down Expand Up @@ -83,6 +89,12 @@ ARGUMENTS
GROUPS target group names.`
}

func (gic *groupInfoCommand) Help() string {
return `rrh group info <GROUPS...>
ARGUMENTS
GROUPS group names to show the information.`
}

func (guc *groupUpdateCommand) Help() string {
return `rrh group update [OPTIONS] <GROUP>
OPTIONS
Expand All @@ -100,6 +112,7 @@ func (group *GroupCommand) Help() string {
return `rrh group <SUBCOMMAND>
SUBCOMMAND
add add new group.
info show information of specified groups.
list list groups (default).
of shows groups of the specified repository.
rm remove group.
Expand All @@ -115,6 +128,7 @@ func (group *GroupCommand) Run(args []string) int {
c.Autocomplete = true
c.Commands = map[string]cli.CommandFactory{
"add": groupAddCommandFactory,
"info": groupInfoCommandFactory,
"update": groupUpdateCommandFactory,
"of": groupOfCommandFactory,
"rm": groupRemoveCommandFactory,
Expand Down Expand Up @@ -211,6 +225,42 @@ func (glc *groupListCommand) parse(args []string) (*groupListOptions, error) {
return opt, nil
}

func printGroupInfo(db *lib.Database, group *lib.Group) {
count := db.ContainsCount(group.Name)
unit := "repositories"
if count == 1 {
unit = "repository"
}
fmt.Printf("%s: %s (%d %s, omit: %v)\n", group.Name, group.Description, count, unit, group.OmitList)
}

func (gic *groupInfoCommand) perform(db *lib.Database, args []string) int {
errs := []error{}
for _, arg := range args {
group := db.FindGroup(arg)
if group == nil {
errs = append(errs, fmt.Errorf("%s: group not found", arg))
continue
}
printGroupInfo(db, group)
}
return printErrors(db.Config, errs)
}

func (gic *groupInfoCommand) Run(args []string) int {
if len(args) == 0 {
fmt.Println(gic.Help())
return 1
}
var config = lib.OpenConfig()
var db, err = lib.Open(config)
if err != nil {
fmt.Println(err.Error())
return 2
}
return gic.perform(db, args)
}

func (goc *groupOfCommand) perform(db *lib.Database, repositoryID string) int {
if !db.HasRepository(repositoryID) {
fmt.Printf("%s: repository not found\n", repositoryID)
Expand Down Expand Up @@ -446,6 +496,13 @@ func (grc *groupRemoveCommand) Synopsis() string {
return "remove given group."
}

/*
Synopsis returns the help message of the command.
*/
func (gic *groupInfoCommand) Synopsis() string {
return "show information of groups."
}

/*
Synopsis returns the help message of the command.
*/
Expand Down

0 comments on commit cec5da2

Please sign in to comment.