Skip to content

Allow control over exec args in docker.#Run #1626

Closed as not planned
Closed as not planned

Description

@helderco

Currently, you can describe a command in docker.#Run with

#Run: {
	command?: {
		// Name of the command to execute
		// Examples: "ls", "/bin/bash"
		name: string

		// Positional arguments to the command
		// Examples: ["/tmp"]
		args: [...string]

		// Command-line flags represented in a civilized form
		// Example: {"-l": true, "-c": "echo hello world"}
		flags: [string]: (string | true)
	}

	_exec: engine.#Exec & {
		args: [command.name] + command._flatFlags + command.args
	}
}

I understand that the flags are built like a struct because it's easier in CUE for composition, but still I have two issues:

  1. I keep forgetting to add name: after command;
  2. This assumes flags always come before positional arguments and I've not always found this to be the case.

Sometimes I'd rather be able to just set the command as an exec array or a simple string, just like in a Dockerfile.

Activity

  1. helderco commented on Feb 19, 2022

    @helderco
    ContributorAuthor

    As suggested by @shykes, if we make name optional, you can just use:

    docker.#Run & {
        command: args: [...]
    }
  2. helderco commented on Mar 9, 2022

    @helderco
    ContributorAuthor

    2. This assumes flags always come before positional arguments and I've not always found this to be the case.

    Here's an example:

    	command: {
    		name: "pip"
    		args: ["install"]
    		flags: "-r": "requirements.txt"
    	}

    This will result in pip -r requirements.txt install, which doesn't work. The flag is for the install sub command.

  3. shykes commented on Mar 9, 2022

    @shykes
    Contributor
    1. This assumes flags always come before positional arguments and I've not always found this to be the case.

    Here's an example:

    	command: {
    		name: "pip"
    		args: ["install"]
    		flags: "-r": "requirements.txt"
    	}

    This will result in pip -r requirements.txt install, which doesn't work. The flag is for the install sub command.

    I think we need to plan a slight re-design of the command interface.. In the meantime, would it be helpful to change the default order, so that flags always come after args? Realistically that's the only fix we can get into 0.2.0-beta.1

  4. helderco commented on Mar 9, 2022

    @helderco
    ContributorAuthor

    Some commands have global flags and sub-command flags, that come before and after some positional arguments.

    So I'd just revert to using args if more control is needed, and keep flags as is for the particular convenience it serves.

  5. shykes commented on Mar 9, 2022

    @shykes
    Contributor

    I agree. And we can also change the meaning of the convenience (from root command flags to subcommand flags) but it's probably the last time we can. In your opinion should we change the convenience to subcommand flags, or keep it at root flags?

  6. helderco commented on Mar 9, 2022

    @helderco
    ContributorAuthor

    I'm leaning towards keeping them as is because it seems the most common case and so the most useful.

  7. shykes commented on Mar 9, 2022

    @shykes
    Contributor

    Works for me.

  8. helderco commented on Mar 9, 2022

    @helderco
    ContributorAuthor

    Still, would rather do:

    -	command: {
    -		name: "python"
    -		args: ["app.py"]
    -	}
    +	command: args: ["python", "app.py"]

    I want to send a PR for making name optional, we've just had other priorities so far. 🙂

  9. helderco commented on Dec 22, 2022

    @helderco
    ContributorAuthor

    Closing since the 0.2 CUE API is frozen, in favor of the GraphQL API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions