diff --git a/docs/lib/git.md b/docs/lib/git.md index 3fb375b..5503e64 100644 --- a/docs/lib/git.md +++ b/docs/lib/git.md @@ -23,11 +23,11 @@ Rebase source branch onto target branch and forcefully push the rebased branch t **Usage** ``` -ggit-base SOURCE [TARGET] [REMOTE] +ggit-base [SOURCE] [TARGET] [REMOTE] ggit-base SOURCE... TARGET REMOTE Params: -SOURCE Branch to be rebased +SOURCE Branch to be rebased. Defaults to current branch in the first form. TARGET Rebase onto this branch. Defaults to 'main' in the first form. REMOTE Remote repository to pull and push. Defaults to 'origin' in the first form. ``` @@ -79,10 +79,10 @@ Merge the source branch into the target branch (performs a fast-forward merge). **Usage** ``` -ggit-merge SOURCE [TARGET] [REMOTE] +ggit-merge [SOURCE] [TARGET] [REMOTE] Params: -SOURCE Branch to be merged +SOURCE Branch to be merged. Defaults to current branch. TARGET Branch to merge into. Defaults to 'main'. REMOTE Remote repository to pull and push. Defaults to 'origin'. ``` @@ -210,10 +210,10 @@ This way you can have the same commits (and history) as remote. **Usage** ``` -ggit-update BRANCH [REMOTE] +ggit-update [BRANCH] [REMOTE] Params: -BRANCH Branch to update +BRANCH Branch to update. Defaults to current branch. REMOTE Remote repository, defaults to 'origin'. ``` diff --git a/docs/lib/github.md b/docs/lib/github.md index 3128829..a431f5b 100644 --- a/docs/lib/github.md +++ b/docs/lib/github.md @@ -95,6 +95,22 @@ EXTRA Optional extra params to 'gh' --- +## ghub-list-license + +List repositories for a GitHub account with license info. + +**Usage** + +``` +ghub-list-license OWNER [EXTRA]... + +Params: +OWNER Owner, GitHub user or organization +EXTRA Optional extra params to 'gh' +``` + +--- + ## ghub-open Open GitHub repository page in web browser. diff --git a/lib/github.sh b/lib/github.sh index 5e7fe12..c04e51b 100644 --- a/lib/github.sh +++ b/lib/github.sh @@ -16,6 +16,20 @@ ghub-list() { gh repo list "${owner}" --limit 100 "${@}" } +## List repos with license info +## +## @param $1 Owner (account) +## @param $@ Extra args to gh +################################# +ghub-list-license() { + local owner="${1?:Owner missing}" + shift + # shellcheck disable=SC2016 + ghub-list "${owner}" "${@}" \ + --json nameWithOwner,description,licenseInfo,visibility \ + --template '{{ tablerow ("NAME" | color "yellow+du") ("DESCRIPTION" | color "yellow+du") ("LICENSE" | color "yellow+du") ("VISIBILITY" | color "yellow+du") }}{{ range . }}{{ $lic := "---" }}{{ with .licenseInfo }}{{ $lic = .name }}{{ end }}{{ tablerow .nameWithOwner .description $lic .visibility }}{{ end }}' +} + ## Get repo names ## ## @param $1 Owner (account) @@ -25,7 +39,9 @@ ghub-get() { local owner="${1?:Owner missing}" shift # shellcheck disable=SC2312 - gh repo list "${owner}" --limit 100 --json nameWithOwner --jq ".[].nameWithOwner" "${@}" | LC_COLLATE=C sort + ghub-list "${owner}" "${@}" \ + --json nameWithOwner \ + --jq '.[].nameWithOwner' | LC_COLLATE=C sort -f } ## Open repo in browser