Sha256: e0fea00b79b6dc3eed9f8eb2e5c6e5243e7ff3bc99cfddc613a2bb0251909aef

Contents?: true

Size: 1.34 KB

Versions: 23

Compression:

Stored size: 1.34 KB

Contents

# Note moving this under Lono::CLI::Opts messes with the zeitwerk autoloader.
# A weird workaround is calling Lono::CLI::Opts right after the autoloader and then it seems to fix itself.
# It may be because there's a custom infleciton cli => CLI. Unsure.
# Unsure if there are other side-effects with the workaround so named this:
# Lono::Opts instead of Lono::CLI::Opts
#
# Also, there's Thor Options class, so this is named Opts to avoid having to fully qualify it.
module Lono
  class Opts
    def initialize(cli)
      @cli = cli
    end

    def clean
      with_cli_scope do
        option :clean, type: :boolean, default: true, desc: "remove all output files before generating"
      end
    end

    def source
      with_cli_scope do
        option :source, desc: "url or path to file with template"
      end
    end

    def stack
      with_cli_scope do
        option :stack, desc: "stack name. defaults to blueprint name."
      end
    end

    def template
      with_cli_scope do
        option :template, desc: "override convention and specify the template file to use"
        option :param, desc: "override convention and specify the param file to use"
        option :variable, desc: "override convention and specify the variable file to use"
      end
    end

  private
    def with_cli_scope(&block)
      @cli.instance_eval(&block)
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
lono-7.5.2 lib/lono/opts.rb
lono-7.5.1 lib/lono/opts.rb
lono-7.5.0 lib/lono/opts.rb
lono-7.4.11 lib/lono/opts.rb
lono-7.4.10 lib/lono/opts.rb
lono-7.4.9 lib/lono/opts.rb
lono-7.4.8 lib/lono/opts.rb
lono-7.4.7 lib/lono/opts.rb
lono-7.4.6 lib/lono/opts.rb
lono-7.4.5 lib/lono/opts.rb
lono-7.4.4 lib/lono/opts.rb
lono-7.4.3 lib/lono/opts.rb
lono-7.4.2 lib/lono/opts.rb
lono-7.4.1 lib/lono/opts.rb
lono-7.4.0 lib/lono/opts.rb
lono-7.3.2 lib/lono/opts.rb
lono-7.3.1 lib/lono/opts.rb
lono-7.3.0 lib/lono/opts.rb
lono-7.2.3 lib/lono/opts.rb
lono-7.2.2 lib/lono/opts.rb