HostKit.CommandLine (host_kit v0.1.0-beta.7)

Copy Markdown View Source

A parsed or built simple command line stored as argv.

Summary

Functions

Builds a command line from a command, positional args, and structured CLI options.

Builds an Elixir command line.

Builds an elixir -e command line.

Builds a Mix task command line.

Normalizes a HostKit command shape into {command, args} argv form.

Types

option_style()

@type option_style() :: :gnu | :equals | :single_dash | :short | :underscore

t()

@type t() :: %HostKit.CommandLine{
  args: [String.t()],
  ast: term(),
  command: String.t(),
  source: String.t() | nil
}

Functions

argv(command, opts \\ [])

@spec argv(
  String.t(),
  keyword()
) :: t()

Builds a command line from a command, positional args, and structured CLI options.

elixir(opts \\ [])

Builds an Elixir command line.

elixir(script_or_args, opts)

@spec elixir(
  keyword() | String.t() | [String.t()],
  keyword()
) :: t()

eval(expression, opts \\ [])

@spec eval(
  String.t(),
  keyword()
) :: t()

Builds an elixir -e command line.

mix(task, opts \\ [])

@spec mix(
  String.t() | atom(),
  keyword()
) :: t()

Builds a Mix task command line.

parse(source)

@spec parse(String.t()) :: {:ok, t()} | {:error, term()}

parse!(source)

@spec parse!(String.t()) :: t()

to_exec(command)

@spec to_exec(t() | String.t() | {term(), [term()]} | [term()]) ::
  {String.t(), [String.t()]}

Normalizes a HostKit command shape into {command, args} argv form.