Skip to content

Commit

Permalink
feat(all): Populating the code.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasz-lobocki committed Sep 12, 2023
1 parent afccbbb commit 7f66daf
Show file tree
Hide file tree
Showing 20 changed files with 1,914 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bin/*
*.code-workspace
10 changes: 5 additions & 5 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ builds:
- arm64
ldflags:
- -s -w
- -X {{.ModulePath}}/main.semVer={{.Summary}} -X {{.ModulePath}}/main.commitHash={{.ShortCommit}}
- -X {{.ModulePath}}/main.isGitDirty={{.IsGitDirty}} -X {{.ModulePath}}/main.isSnapshot={{.IsSnapshot}}
- -X {{.ModulePath}}/main.goOs={{.Os}} -X {{.ModulePath}}/main.goArch={{.Arch}}
- -X {{.ModulePath}}/main.gitUrl={{.GitURL}} -X {{.ModulePath}}/main.builtBranch={{.Branch}}
- -X {{.ModulePath}}/main.builtDate={{.Date}} -X {{.ModulePath}}/main.builtBy=goreleaser
- -X {{.ModulePath}}/cmd.semVer={{.Summary}} -X {{.ModulePath}}/cmd.commitHash={{.ShortCommit}}
- -X {{.ModulePath}}/cmd.isGitDirty={{.IsGitDirty}} -X {{.ModulePath}}/cmd.isSnapshot={{.IsSnapshot}}
- -X {{.ModulePath}}/cmd.goOs={{.Os}} -X {{.ModulePath}}/cmd.goArch={{.Arch}}
- -X {{.ModulePath}}/cmd.gitUrl={{.GitURL}} -X {{.ModulePath}}/cmd.builtBranch={{.Branch}}
- -X {{.ModulePath}}/cmd.builtDate={{.Date}} -X {{.ModulePath}}/cmd.builtBy=goreleaser

archives:
- format: tar.gz
Expand Down
4 changes: 2 additions & 2 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ cookiecutter \
- package_name: **`gitas`**;
package_short_description: `Multiple git repos management.`

- package_version: `1.3.4`
- package_version: `0.1.0`

- author_name: `Lukasz Lobocki`;
open_source_license: `CC0 v1.0 Universal`
Expand All @@ -44,4 +44,4 @@ open_source_license: `CC0 v1.0 Universal`

### on

`2023-09-12 10:23:39 +0200`
`2023-09-12 07:41:14 +0200`
84 changes: 82 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,84 @@
# gitas ![Static](https://img.shields.io/badge/jasyr-lakmusowy-peru?style=for-the-badge&labelColor=linen)
# gitas ![Static](https://img.shields.io/badge/myjnia-syfon-brown?style=for-the-badge&labelColor=lightgoldenrodyellow)

Multiple git repos management.
This tool has two features:

- display the **status** of multiple git repos side by side
- delegate **shell** commands on multiple git repos

Unlike [gita](https://github.com/nosarthur/gita), it does not require maintenance of repositiories' list. It works on all repos found recursively in the given path.

## gitas status

Show status of each git repository found in PATH

```bash
gitas status [PATH] [flags]
```

### Examples

![Alt text](samples/Screenshot_status.png)

```bash
gitas status ~ --name=p -b=true -o=n
gitas status
gitas status /home --time=false
```

See also [markdown](samples/markdown_example.md) and [json](samples/json_example.json) example results.

### Flags

```
-n, --name {u|p|s} name shown: unique|path|short (default u)
-t, --time time of last commit shown (default true)
-f, --format {r|i} format time: relative|iso (default r)
-b, --branch branch shown
-r, --remote remote shown
-l, --url url shown
-d, --dirty dirty shown (default true)
-u, --untracked untracked shown
-s, --stash stash shown
-o, --order {t|n} order: time|name (default t)
-e, --emit {t|j|m} emit format: table|json|markdown (default t)
-h, --help help for status
```

### Flags inherited from parent commands

```
--logging int logging level [0...3] (default 0)
```

## gitas shell

Execute "command" for each git repository found in PATH

```bash
gitas shell [PATH] "command" [flags]
```

### Examples

![Alt text](samples/Screenshot_shell.png)

```bash
gitas shell /home "ls"
gitas shell ~ "git describe --abbrev=0 --tags"
gitas shell "ls | grep 'P'"
```

### Flags

```
-h, --help help for shell
```

### Flags inherited from parent commands

```
--logging int logging level [0...3] (default 0)
```

## Build

Expand All @@ -12,6 +90,8 @@ goreleaser build --clean

`gitas` was created by Lukasz Lobocki. It is licensed under the terms of the CC0 v1.0 Universal license.

Inspired by [gita](https://github.com/nosarthur/gita).

All components used retain their original licenses.

## Credits
Expand Down
65 changes: 65 additions & 0 deletions cmd/choice_flag.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package cmd

import (
"fmt"
"strings"
)

type tChoice struct {
Allowed []string // Slice of allowed values
Value string // Defaulted value
}

/*
newChoice give a list of allowed flag parameters, where the second argument is the default
'allowed' slice of allowed strings
'defaulted' default string
*/
func newChoice(allowed []string, defaulted string) *tChoice {
return &tChoice{
Allowed: allowed,
Value: defaulted,
}
}

/*
Set is called upon flag provisioning, validates its value
'p' string to be put into the flag
*/
func (a *tChoice) Set(p string) error {

isIncluded := func(opts []string, val string) bool {
for _, opt := range opts {
if val == opt {
return true
}
}
return false
}

if !isIncluded(a.Allowed, p) {
return fmt.Errorf("%s is not included in {%s}", p, strings.Join(a.Allowed, "|"))
}

/* Set the value */

a.Value = p

return nil
}

/*
String returns flag value
*/
func (a tChoice) String() string {
return a.Value
}

/*
Type returns text for help purposes
*/
func (a *tChoice) Type() string {
return fmt.Sprintf("{%s}", strings.Join(a.Allowed, "|"))
}
Loading

0 comments on commit 7f66daf

Please sign in to comment.