Sha256: 5c49535d28a2f71a6cf7564aa251b7daa7cc77fb6dbcf2840011c732ea1948f9
Contents?: true
Size: 1.6 KB
Versions: 5
Compression:
Stored size: 1.6 KB
Contents
# frozen_string_literal: true require "dry/inflector" require "dry/files" require "shellwords" module Hanami module CLI module Commands module App module Generate # @since 2.1.0 # @api private class Part < App::Command DEFAULT_SKIP_TESTS = false private_constant :DEFAULT_SKIP_TESTS argument :name, required: true, desc: "Part name" option :slice, required: false, desc: "Slice name" option \ :skip_tests, required: false, type: :flag, default: DEFAULT_SKIP_TESTS, desc: "Skip test generation" example [ %(book (MyApp::Views::Parts::Book)), %(book --slice=admin (Admin::Views::Parts::Book)), ] attr_reader :generator private :generator # @since 2.0.0 # @api private def initialize( fs:, inflector:, generator: Generators::App::Part.new(fs: fs, inflector: inflector), **opts ) super(fs: fs, inflector: inflector, **opts) @generator = generator end # @since 2.0.0 # @api private def call(name:, slice: nil, skip_tests: DEFAULT_SKIP_TESTS, **) # rubocop:disable Lint/UnusedMethodArgument slice = inflector.underscore(Shellwords.shellescape(slice)) if slice generator.call(app.namespace, name, slice) end end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems