Sha256: fa6d72b1dca7892101d3ac005a0ca6c5818090027babbd28f0fbd1e9183126b5

Contents?: true

Size: 1.55 KB

Versions: 25

Compression:

Stored size: 1.55 KB

Contents

class Ufo::CLI
  module Help
    extend ActiveSupport::Concern

    class_methods do
      def main_commands
        %w[
          destroy
          exec
          logs
          ps
          ship
        ]
      end

      def help(shell, subcommand)
        list = printable_commands(true, subcommand)
        list.sort! { |a, b| a[0] <=> b[0] }
        filter = Proc.new do |command, desc|
          command = command.sub(/ --.*/,'')
          detected = main_commands.detect do |c|
            expr = "^ufo #{c}$"
            command =~ Regexp.new(expr)
          end
          detected
        end
        main = list.select(&filter)
        other = list.reject(&filter)

        shell.say <<~EOL
          Usage: ufo COMMAND [args]
          The available commands are listed below.
          The primary workflow commands are given first, followed by
          less common or more advanced commands.
        EOL
        shell.say "\nMain Commands:\n\n"
        shell.print_table(main, :indent => 2, :truncate => true)
        shell.say "\nOther Commands:\n\n"
        shell.print_table(other, :indent => 2, :truncate => true)
        shell.say <<~EOL

          For more help on each command, you can use the -h option. Example:

              ufo ship -h

          CLI Reference also available at: https://ufoships.com/reference/
        EOL
      end
    end

    def text(namespaced_command)
      path = namespaced_command.to_s.gsub(':','/')
      path = File.expand_path("../help/#{path}.md", __FILE__)
      IO.read(path) if File.exist?(path)
    end

    extend self
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
ufo-6.3.13 lib/ufo/cli/help.rb
ufo-6.3.12 lib/ufo/cli/help.rb
ufo-6.3.11 lib/ufo/cli/help.rb
ufo-6.3.10 lib/ufo/cli/help.rb
ufo-6.3.9 lib/ufo/cli/help.rb
ufo-6.3.8 lib/ufo/cli/help.rb
ufo-6.3.7 lib/ufo/cli/help.rb
ufo-6.3.6 lib/ufo/cli/help.rb
ufo-6.3.5 lib/ufo/cli/help.rb
ufo-6.3.4 lib/ufo/cli/help.rb
ufo-6.3.3 lib/ufo/cli/help.rb
ufo-6.3.2 lib/ufo/cli/help.rb
ufo-6.3.1 lib/ufo/cli/help.rb
ufo-6.3.0 lib/ufo/cli/help.rb
ufo-6.2.5 lib/ufo/cli/help.rb
ufo-6.2.4 lib/ufo/cli/help.rb
ufo-6.2.3 lib/ufo/cli/help.rb
ufo-6.2.2 lib/ufo/cli/help.rb
ufo-6.2.1 lib/ufo/cli/help.rb
ufo-6.2.0 lib/ufo/cli/help.rb