module Kontena::Cli class SubcommandLoader attr_reader :path # Create a subcommand loader instance # # @param [String] path path to command definition def initialize(path) @path = path end # Takes something like /foo/bar/cli/master/foo_coimmand and returns [:Master, :FooCommand] # # @param path [String] # @return [Array] def symbolize_path(path) path.gsub(/.*\/cli\//, '').split('/').map do |path_part| path_part.split('_').map{ |e| e.capitalize }.join end.map(&:to_sym) end # Takes an array such as [:Foo] or [:Cli, :Foo] and returns [:Kontena, :Cli, :Foo] def prepend_kontena_cli(tree) [:Kontena, :Cli] + (tree - [:Cli]) end # Takes an array such as [:Master, :FooCommand] and returns Master::FooCommand # # @param tree [Array