Skip to content

Commit

Permalink
Merge 81c7c95 into 8a2350c
Browse files Browse the repository at this point in the history
  • Loading branch information
saheljalal committed Feb 3, 2022
2 parents 8a2350c + 81c7c95 commit 442f47c
Show file tree
Hide file tree
Showing 8 changed files with 596 additions and 133 deletions.
19 changes: 19 additions & 0 deletions cmd/move.go
@@ -0,0 +1,19 @@
package cmd

import (
"github.com/spf13/cobra"
)

// moveCmd represents the move command
var moveCmd = &cobra.Command{
Use: "move",
Short: "Move a command in nostromo manifest",
Long: "Move a command in nostromo manifest",
Run: func(cmd *cobra.Command, args []string) {
printUsage(cmd)
},
}

func init() {
rootCmd.AddCommand(moveCmd)
}
50 changes: 50 additions & 0 deletions cmd/movecmd.go
@@ -0,0 +1,50 @@
package cmd

import (
"os"

"github.com/pokanop/nostromo/task"
"github.com/spf13/cobra"
)

var rename string

// movecmdCmd represents the movecmd command
var movecmdCmd = &cobra.Command{
Use: "cmd [src.key.path] [dest.key.path] [options]",
Short: "Move a command in nostromo manifest",
Long: `Move a command in nostromo manifest for a given key path.
A key path is a '.' delimited string, e.g., "key.path" which represents
the alias which can be run as "key path" for the actual command provided.
Manipulate the core nostromo manifest by moving command nodes.
Using move, take a source key path and shift it to the destination
key path with all subcommands in tow.
If the destination key path does not exist, it will be created
and the node will be moved there. Optionally provide a description
with -d to the destination.
To move a node to the root, do not provide a destination key path.
To rename a node only, pass the -r flag with a name to use.`,
Args: cobra.RangeArgs(1, 2),
Run: func(cmd *cobra.Command, args []string) {
var dest string
if len(args) > 1 {
dest = args[1]
}
if len(rename) == 0 {
os.Exit(task.MoveCommand(args[0], dest, description))
} else {
os.Exit(task.RenameCommand(args[0], rename, description))
}
},
}

func init() {
moveCmd.AddCommand(movecmdCmd)

movecmdCmd.Flags().StringVarP(&description, "description", "d", "", "Description of the destination to move command")
movecmdCmd.Flags().StringVarP(&rename, "rename", "r", "", "Rename command instead of moving")
}
79 changes: 79 additions & 0 deletions examples/docker.yaml
@@ -0,0 +1,79 @@
name: docker
source: https://github.com/pokanop/nostromo/blob/main/examples/docker.yaml
path: /Users/gopher/.nostromo/ships/docker.yaml
version:
uuid: e1eea91e-6a6f-4838-b12b-7063732e4a56
semver: 0.9.2
gitcommit: 8a2350c0d5700cf2066977089f133af7daf7df60
builddate: "2022-02-02T23:29:30Z"
config:
verbose: false
aliasesonly: false
mode: 0
backupcount: 10
commands:
docker:
keypath: dock
name: docker
alias: dock
aliasonly: false
description: Alias for docker
commands:
clean:
keypath: dock.clean
name: ps -a -q |xargs docker rm
alias: clean
aliasonly: false
description: Remove Docker containers using docker rm
commands: {}
subs: {}
code:
language: ""
snippet: ""
mode: 0
disabled: false
rmi:
keypath: dock.rmi
name: rmi $(docker images -q)
alias: rmi
aliasonly: false
description: Remove Docker images using docker rmi
commands: {}
subs: {}
code:
language: ""
snippet: ""
mode: 0
disabled: false
stop:
keypath: dock.stop
name: ps -q |xargs docker stop
alias: stop
aliasonly: false
description: Stop running Docker containers
commands: {}
subs: {}
code:
language: ""
snippet: ""
mode: 0
disabled: false
vol:
keypath: dock.vol
name: volume rm $(docker volume ls -qf dangling=true)
alias: vol
aliasonly: false
description: Remove dangling Docker volumes
commands: {}
subs: {}
code:
language: ""
snippet: ""
mode: 0
disabled: false
subs: {}
code:
language: ""
snippet: ""
mode: 0
disabled: false
144 changes: 144 additions & 0 deletions examples/edit.yaml
@@ -0,0 +1,144 @@
name: edit
source: https://github.com/pokanop/nostromo/blob/main/examples/edit.yaml
path: /Users/gopher/.nostromo/ships/edit.yaml
version:
uuid: 08f24962-402a-4323-a843-71c594b1c816
semver: 0.9.2
gitcommit: 8a2350c0d5700cf2066977089f133af7daf7df60
builddate: "2022-02-02T23:29:30Z"
config:
verbose: false
aliasesonly: false
mode: 0
backupcount: 10
commands:
"":
keypath: edit
name: ""
alias: edit
aliasonly: false
description: ""
commands:
bash:
keypath: edit.bash
name: vim ~/.bashrc
alias: bash
aliasonly: false
description: Edit bashrc config file using vim
commands: {}
subs: {}
code:
language: ""
snippet: ""
mode: 0
disabled: false
bash_profile:
keypath: edit.bash_profile
name: vim ~/.bash_profile
alias: bash_profile
aliasonly: false
description: Edit bash_profile config file using vim
commands: {}
subs: {}
code:
language: ""
snippet: ""
mode: 0
disabled: false
nostromo:
keypath: edit.nostromo
name: vim ~/.nostromo/manifest.yaml
alias: nostromo
aliasonly: false
description: Edit nostromo manifest file using vim
commands: {}
subs: {}
code:
language: ""
snippet: ""
mode: 0
disabled: false
p10k:
keypath: edit.p10k
name: vim ~/.p10k.zsh
alias: p10k
aliasonly: false
description: Edit p10k config file in vim
commands: {}
subs: {}
code:
language: ""
snippet: ""
mode: 0
disabled: false
profile:
keypath: edit.profile
name: vim ~/.profile
alias: profile
aliasonly: false
description: Edit profile config file using vim
commands: {}
subs: {}
code:
language: ""
snippet: ""
mode: 0
disabled: false
ssh:
keypath: edit.ssh
name: vim ~/.ssh/config
alias: ssh
aliasonly: false
description: Edit ssh config file in vim
commands:
hosts:
keypath: edit.ssh.hosts
name: vim ~/.ssh/hosts
alias: hosts
aliasonly: false
description: Edit ssh hosts file in vim
commands: {}
subs: {}
code:
language: ""
snippet: ""
mode: 2
disabled: false
subs: {}
code:
language: ""
snippet: ""
mode: 0
disabled: false
terminalizer:
keypath: edit.terminalizer
name: vim ~/.terminalizer/config.yml
alias: terminalizer
aliasonly: false
description: Edit terminalizer config file
commands: {}
subs: {}
code:
language: ""
snippet: ""
mode: 0
disabled: false
zsh:
keypath: edit.zsh
name: vim ~/.zshrc
alias: zsh
aliasonly: false
description: Edit zsh config file using vim
commands: {}
subs: {}
code:
language: ""
snippet: ""
mode: 0
disabled: false
subs: {}
code:
language: ""
snippet: ""
mode: 0
disabled: false

0 comments on commit 442f47c

Please sign in to comment.