Skip to content

Commit

Permalink
fix: improve autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Aug 25, 2021
1 parent 16f98da commit 33cd246
Show file tree
Hide file tree
Showing 2 changed files with 275 additions and 3 deletions.
266 changes: 266 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,271 @@ done-with-branch: |
# Commands
<!-- commands -->
* [`multi add ENTITY`](#multi-add-entity)
* [`multi alias KEYVALUE`](#multi-alias-keyvalue)
* [`multi alias resolve ALIAS`](#multi-alias-resolve-alias)
* [`multi cd REPO`](#multi-cd-repo)
* [`multi exec REPO`](#multi-exec-repo)
* [`multi list`](#multi-list)
* [`multi open REPO`](#multi-open-repo)
* [`multi remove REPO`](#multi-remove-repo)
* [`multi setup`](#multi-setup)
* [`multi view REPO`](#multi-view-repo)
* [`multi where REPO`](#multi-where-repo)

## `multi add ENTITY`

Add a github org or repo. Requires GH_TOKEN to be set in the environment.

```
USAGE
$ multi add [ENTITY] [--method ssh|https]

ARGUMENTS
ENTITY Github org, repo, or url to add

FLAGS
--method=<option> [default: ssh] Method to use for cloning.
<options: ssh|https>

DESCRIPTION
Add a github org or repo. Requires GH_TOKEN to be set in the environment.

EXAMPLES
Add a github org

$ multi add my-github-org

Add a github org by url

$ multi add https://github.com/my-github-org

Add a github repo by name

$ multi add my-github-org/my-repo

Add a github repo by url

$ multi add https://github.com/my-github-org/my-repo
```
_See code: [src/commands/add.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v1.4.0/src/commands/add.ts)_
## `multi alias KEYVALUE`
Provide an empty to value to unset the alias. This feature is not support on Windows.
```
USAGE
$ multi alias [KEYVALUE] [--interactive]

ARGUMENTS
KEYVALUE alias=value

FLAGS
--interactive Open a vim editor to add your alias

DESCRIPTION
Set or unset an executable alias.

Provide an empty to value to unset the alias. This feature is not support on Windows.

EXAMPLES
Set an alias

$ multi alias build=yarn build

Set an alias that uses multi exec

$ multi alias circle=multi exec . open https://app.circleci.com/pipelines/github/{repo.fullName}

Unset an alias

$ multi alias build=

Set an alias interactively

$ multi alias build --interactive
```
_See code: [src/commands/alias.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v1.4.0/src/commands/alias.ts)_
## `multi alias resolve ALIAS`
Return the value of an alias.
```
USAGE
$ multi alias resolve [ALIAS]

ARGUMENTS
ALIAS Name of alias to resolve..

DESCRIPTION
Return the value of an alias.
```
## `multi cd REPO`
cd into a github repository.
```
USAGE
$ multi cd [REPO]

ARGUMENTS
REPO Name of repository.

DESCRIPTION
cd into a github repository.
```
_See code: [src/commands/cd.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v1.4.0/src/commands/cd.ts)_
## `multi exec REPO`
Execute a command or script in a repository.
```
USAGE
$ multi exec [REPO]

ARGUMENTS
REPO Name of repository to execute in. Use "." to specify the current working directory.

DESCRIPTION
Execute a command or script in a repository.

ALIASES
$ multi x

EXAMPLES
Execute a script in a different repository

$ multi exec my-repo yarn compile

Execute a script in the current working directory

$ multi exec . yarn compile

Interpolate values into command execution

$ multi exec . open https://app.circleci.com/pipelines/github/{repo.fullName}
```
_See code: [src/commands/exec.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v1.4.0/src/commands/exec.ts)_
## `multi list`
List all added repositories.
```
USAGE
$ multi list

DESCRIPTION
List all added repositories.

ALIASES
$ multi ls
```
_See code: [src/commands/list.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v1.4.0/src/commands/list.ts)_
## `multi open REPO`
Open a github repository.
```
USAGE
$ multi open [REPO]

ARGUMENTS
REPO [default: .] Name of repository.

DESCRIPTION
Open a github repository.

ALIASES
$ multi o
```
_See code: [src/commands/open.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v1.4.0/src/commands/open.ts)_
## `multi remove REPO`
Remove a github repository from your local filesystem.
```
USAGE
$ multi remove [REPO]

ARGUMENTS
REPO Name of repository.

DESCRIPTION
Remove a github repository from your local filesystem.

ALIASES
$ multi rm
```
_See code: [src/commands/remove.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v1.4.0/src/commands/remove.ts)_
## `multi setup`
Setup multi
```
USAGE
$ multi setup [-d <value>]

FLAGS
-d, --directory=<value> Location to setup repositories.

DESCRIPTION
Setup multi
```
_See code: [src/commands/setup.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v1.4.0/src/commands/setup.ts)_
## `multi view REPO`
View a github repository.
```
USAGE
$ multi view [REPO]

ARGUMENTS
REPO Name of repository.

DESCRIPTION
View a github repository.

ALIASES
$ multi v
```
_See code: [src/commands/view.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v1.4.0/src/commands/view.ts)_
## `multi where REPO`
Print location of a github repository.
```
USAGE
$ multi where [REPO] [--remote]

ARGUMENTS
REPO Name of repository.

FLAGS
--remote Return url of repository.

DESCRIPTION
Print location of a github repository.
```
_See code: [src/commands/where.ts](https://github.com/mdonnalley/multiple-repo-manager/blob/v1.4.0/src/commands/where.ts)_
<!-- commandsstop -->
12 changes: 9 additions & 3 deletions src/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ import { ConfigFile } from './configFile';
import { BashRc } from './bashRc';
import { Aliases } from './aliases';

const AUTO_COMPLETE = `_multi_autocomplete()
const AUTO_COMPLETE = `#/usr/bin/env bash
_get_repo_autocomplete()
{
echo $(ls -d @CODE_DIRECTORY@/**/* | sed 's/\\/*$//g' | awk -F/ '{print $(NF-1)"/"$(NF)" "$(NF)}')
}
_multi_autocomplete()
{
local cur prev
local code_dir=@CODE_DIRECTORY@
local aliases=$(sed -e 's/\:.*//;s/ .*//' @ALIASES_PATH@ | tr '\\n' ' ')
cur=\${COMP_WORDS[COMP_CWORD]}
Expand All @@ -20,7 +26,7 @@ const AUTO_COMPLETE = `_multi_autocomplete()
2)
case \${prev} in
@REPO_COMMANDS@)
COMPREPLY=($( compgen -W "$(ls -d $code_dir/**/* | xargs basename)" -- $cur ))
COMPREPLY=($( compgen -W "$(_get_repo_autocomplete)" -- $cur ))
;;
esac
;;
Expand Down

0 comments on commit 33cd246

Please sign in to comment.