Skip to content

Commit

Permalink
start alias: fix start alias with --detach
Browse files Browse the repository at this point in the history
  • Loading branch information
hanjm committed Jan 24, 2022
1 parent eaee4e5 commit d114437
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@
*.swp
*~
*.un~

.idea
10 changes: 9 additions & 1 deletion cmd/start_alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ The flags provided through this command can be used to override the one with the
same name stored in the alias.
`,
Args: func(cmd *cobra.Command, args []string) error {
// for the child process when the `--detached` flag is used.
if conf.Id != "" {
aliasName = conf.Id
return nil
}
if len(args) < 1 {
return errors.New("alias name not provided")
}
Expand Down Expand Up @@ -67,6 +72,9 @@ func init() {
startAliasCmd.Flags().BoolVarP(&conf.Verbose, "verbose", "v", false, "increase log verbosity")
startAliasCmd.Flags().BoolVarP(&conf.Insecure, "insecure", "i", false, "skip host key validation when connecting to ssh server")
startAliasCmd.Flags().BoolVarP(&conf.Detach, "detach", "x", false, "run process in background")

// id is a hidden flag used to carry the unique identifier of the instance to
// the child process when the `--detached` flag is used.
startAliasCmd.Flags().StringVarP(&conf.Id, mole.IdFlagName, "", "", "")
_ = startAliasCmd.Flags().MarkHidden(mole.IdFlagName)
startCmd.AddCommand(startAliasCmd)
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/hpcloud/tail v1.0.0
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
github.com/kevinburke/ssh_config v0.0.0-20190630040420-2e50c441276c
github.com/mitchellh/go-ps v1.0.0 // indirect
github.com/mitchellh/go-ps v1.0.0
github.com/mitchellh/mapstructure v1.4.1
github.com/pelletier/go-buffruneio v0.2.0 // indirect
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2
Expand Down

0 comments on commit d114437

Please sign in to comment.