-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
implement process entrypoint and run cmd #89
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9aa5935
implement process entrypoint and run cmd
adrian-gierakowski 282f742
add flake check
adrian-gierakowski b99cd40
fix merger_test.go after turning Command into pointer
adrian-gierakowski b2b59c2
fix typo: it's => its
adrian-gierakowski 33eef85
use either Command (if not empty), or Entrypoint, not both
adrian-gierakowski d787b8b
don't fail if both Command and Entrypoint are empty
adrian-gierakowski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,5 @@ type Commander interface { | |
StderrPipe() (io.ReadCloser, error) | ||
Stop(int, bool) error | ||
SetCmdArgs() | ||
AttachIo() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"github.com/f1bonacc1/process-compose/src/api" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// runCmd represents the up command | ||
var runCmd = &cobra.Command{ | ||
Use: "run PROCESS [flags] -- [process_args]", | ||
Short: "Run PROCESS in the foreground, and its dependencies in the background", | ||
Long: `Run selected process with std(in|out|err) attached, while other processes run in the background. | ||
Command line arguments, provided after --, are passed to the PROCESS.`, | ||
Args: cobra.MinimumNArgs(1), | ||
// Args: cobra.ExactArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
*pcFlags.Headless = false | ||
|
||
processName := args[0] | ||
|
||
if len(args) > 1 { | ||
argsLenAtDash := cmd.ArgsLenAtDash() | ||
if argsLenAtDash != 1 { | ||
message := "Extra positional arguments provided! To pass args to PROCESS, separate them from process-compose arguments with: --" | ||
fmt.Println(message) | ||
os.Exit(1) | ||
} | ||
args = args[argsLenAtDash:] | ||
} else { | ||
// Clease args as they will contain the processName | ||
args = []string{} | ||
} | ||
|
||
runner := getProjectRunner( | ||
[]string{processName}, | ||
*pcFlags.NoDependencies, | ||
processName, | ||
args, | ||
) | ||
|
||
api.StartHttpServer(false, *pcFlags.PortNum, runner) | ||
runProject(runner) | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(runCmd) | ||
F1bonacc1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
runCmd.Flags().BoolVarP(pcFlags.NoDependencies, "no-deps", "", *pcFlags.NoDependencies, "don't start dependent processes") | ||
runCmd.Flags().AddFlag(rootCmd.Flags().Lookup("config")) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
p.procConf.Executable
isbash
andp.procConf.Args
are[]string{"-c", "echo Hi"}
,p.extraArgs
will be ignored.Instead of that line, I call
p.mergeExtraArgs()
:What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you give an example of the final command you’d like executed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
run ls
will ignore the extraArg/tmp
It worked well with
entrypoint
instead ofcommand
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This prints:
args: 0 1 2
bash -c 'echo args: $0 $1 $2' 0 1 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try:
bash -c "ls" /tmp
vs.
bash -c "ls /tmp"