lib/gemsmith/templates/%project_name%/lib/%project_path%/cli/shell.rb.erb in gemsmith-19.8.0 vs lib/gemsmith/templates/%project_name%/lib/%project_path%/cli/shell.rb.erb in gemsmith-20.0.0

- old
+ new

@@ -1,33 +1,36 @@ -require "core" +require "sod" <% namespace do %> module CLI # The main Command Line Interface (CLI) object. class Shell - include Actions::Import[:config, :kernel, :logger, :specification] + include Import[:defaults_path, :xdg_config, :specification] - def initialize(parser: Parser.new, **) + def initialize(context: Sod::Context, dsl: Sod, **) super(**) - @parser = parser + @context = context + @dsl = dsl end - def call arguments = Core::EMPTY_ARRAY - act_on parser.call(arguments) - rescue OptionParser::ParseError => error - logger.error { error.message } - end + def call(...) = cli.call(...) private - attr_reader :parser + attr_reader :context, :dsl - def act_on configuration - case configuration - in action_config: Symbol => action then config.call action - in action_version: true then kernel.puts specification.labeled_version - else kernel.puts parser.to_s + def cli + context = build_context + + dsl.new <%= configuration.project_levels.positive? ? configuration.project_name.inspect : configuration.project_name.to_sym.inspect %>, banner: specification.banner do + on(Sod::Prefabs::Commands::Config, context:) + on(Sod::Prefabs::Actions::Version, context:) + on Sod::Prefabs::Actions::Help, self end + end + + def build_context + context[defaults_path:, xdg_config:, version_label: specification.labeled_version] end end end <% end %>