From 785cff06e4e7611aee6ba45ec50dff2e4766238d Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Thu, 22 Aug 2024 15:20:31 -0400 Subject: [PATCH] improvement: add `--with-args` to pass additional args to installers --- installer/lib/mix/tasks/igniter.new.ex | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/installer/lib/mix/tasks/igniter.new.ex b/installer/lib/mix/tasks/igniter.new.ex index 03e3e7c..cbefed6 100644 --- a/installer/lib/mix/tasks/igniter.new.ex +++ b/installer/lib/mix/tasks/igniter.new.ex @@ -9,6 +9,11 @@ defmodule Mix.Tasks.Igniter.New do * `--install` - A comma-separated list of dependencies to install using `mix igniter.install` after creating the project. * `--example` - Request example code to be added to the project when installing packages. * `--with` - The command to use instead of `new`, i.e `phx.new` + * `--with-args` - Additional arguments to pass to the installer provided in `--with` + + Example + + mix igniter.new my_project --install foo,bar,baz --with=phx.new --with-args="--no-ecto" """ @shortdoc "Creates a new Igniter application" use Mix.Task @@ -39,10 +44,16 @@ defmodule Mix.Tasks.Igniter.New do "The first positional argument must be a project name that starts with a dash, got: #{name}" end - {options, argv, _errors} = + {options, _argv, _errors} = OptionParser.parse(argv, - strict: [install: :keep, local: :string, example: :boolean, with: :string], - aliases: [i: :install, l: :local, e: :example, w: :with] + strict: [ + install: :keep, + local: :string, + example: :boolean, + with: :string, + with_args: :string + ], + aliases: [i: :install, l: :local, e: :example, w: :with, wa: :with_args] ) install_with = options[:with] || "new" @@ -68,7 +79,7 @@ defmodule Mix.Tasks.Igniter.New do exit({:shutdown, 1}) end - Mix.Task.run(install_with, [name | argv]) + Mix.Task.run(install_with, [name | OptionParser.split(options[:with_args] || "")]) version_requirement = if options[:local] do