Capstone.New.Options (Capstone v0.33.3)

Copy Markdown View Source

The mix capstone.new argv contract: exactly one switch, --path.

Illegal combinations are unrepresentable: parse!/1 either returns a fully populated struct or raises. --path is the only recognised switch — there is no NAME positional and no --base/--github-org/--module/--app/ --capstone-path any more: target.exs (read via Capstone.Config, which lives in this same project) already carries everything those flags used to supply.

Summary

Types

Which stock project generator/1 produces: :otp runs plain mix new; :api, :web and :both all run mix phx.new against the same stock tree (see generator_argv/1 for why the three don't diverge here).

Where mix capstone.new fetches its own :capstone dev dependency from — hex, or a local path for development.

t()

Functions

The dependency line to splice into the generated project's deps/0.

Every plugin that should actually be installed: base-implied plugins plus whatever was explicitly declared, deduplicated. This is the ONLY place the two lists merge — plugins: itself (declared-only) is never mutated, so target.exs (written from plugins:, never from this) stays an honest record of what the user asked for.

Builds a %Capstone.New.Options{} from an already-validated %Capstone.Config{}.

The Mix task that generates this base's stock project.

The argv to hand the generator.

Plugins base implies, in addition to whatever target.exs lists explicitly.

Parses argv (just --path PATH) into a fully validated %Capstone.New.Options{}.

Types

base()

@type base() :: :otp | :api | :web | :both

Which stock project generator/1 produces: :otp runs plain mix new; :api, :web and :both all run mix phx.new against the same stock tree (see generator_argv/1 for why the three don't diverge here).

dep_source()

@type dep_source() :: {:hex, String.t()} | {:path, Path.t()}

Where mix capstone.new fetches its own :capstone dev dependency from — hex, or a local path for development.

t()

@type t() :: %Capstone.New.Options{
  app: atom(),
  base: base(),
  capstone: dep_source(),
  github_org: String.t(),
  module: module(),
  name: String.t(),
  plugins: [atom()]
}

Functions

dep_line(options)

@spec dep_line(t()) :: binary()

The dependency line to splice into the generated project's deps/0.

effective_plugins(opts)

@spec effective_plugins(t()) :: [atom()]

Every plugin that should actually be installed: base-implied plugins plus whatever was explicitly declared, deduplicated. This is the ONLY place the two lists merge — plugins: itself (declared-only) is never mutated, so target.exs (written from plugins:, never from this) stays an honest record of what the user asked for.

from_config!(config)

@spec from_config!(Capstone.Config.t()) :: t()

Builds a %Capstone.New.Options{} from an already-validated %Capstone.Config{}.

capstone is always {:hex, @default_requirement} here: target.exs has no dependency-source field — it describes the generated project's identity, not the generator's own development conveniences. A {:path, ...} source stays constructible directly (see Capstone.New.Factory's options_factory/0 and its callers), just not through this function.

generator(options)

@spec generator(t()) :: String.t()

The Mix task that generates this base's stock project.

generator_argv(opts)

@spec generator_argv(t()) :: [String.t()]

The argv to hand the generator.

:api, :web and :both all produce the SAME stock tree, and that is not an oversight: priv/baselines.exs records :web as derived_from: :api plus the :web_layer plugin, so the asset pipeline arrives when that plugin is applied and never from phx.new. :both follows the identical reasoning: it is a project that will eventually carry both layers via plugins, not a different stock tree to generate. Generating any of the three with HTML and assets here would hand a plugin a tree it did not derive against.

implied_plugins(base)

@spec implied_plugins(base()) :: [atom()]

Plugins base implies, in addition to whatever target.exs lists explicitly.

:api implies nothing — it is the bare tree every other base is generated from and derived against. :web and :both both imply :web_layer: the LiveView/Svelte layer never comes from the generator (generator_argv/1 strips --no-html --no-assets for all three phx.new-driven bases identically), only from this plugin being applied.

parse!(argv)

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

Parses argv (just --path PATH) into a fully validated %Capstone.New.Options{}.