Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

start alias: fix start alias with --detach #184

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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