class Clio::Usage::Command

Command

This is the toplevel “main” command.

Public Class Methods

new(name=nil, &block) click to toggle source

New Usage.

Calls superclass method
# File lib/clio/usage/command.rb, line 15
def initialize(name=nil, &block)
  name ||= File.basename($0)
  super(name, &block)
end

Private Class Methods

cache_file() click to toggle source
# File lib/clio/usage/command.rb, line 150
def self.cache_file
  File.join(File.expand_path('~'), '.cache', 'clio', "#{name}.yaml")
end
load_cache() click to toggle source
# File lib/clio/usage/command.rb, line 154
def self.load_cache
  if File.file?(cache_file)
    YAML.load(File.new(cache_file))
  end
end

Public Instance Methods

cache() click to toggle source

Cache usage into a per-user cache file for reuse. This can be used to greatly speed up tab completion.

# File lib/clio/usage/command.rb, line 138
def cache
  File.open(cache_file, 'w'){ |f| f << to_yaml }
end
parse(argv) click to toggle source

alias_method :[], :command

ARRAY NOTATION
# File lib/clio/usage/command.rb, line 131
def parse(argv)
  Parser.new(self, argv).parse #(argv)
end

Private Instance Methods

cache_file() click to toggle source

TODO: Use XDG

# File lib/clio/usage/command.rb, line 146
def cache_file
  File.join(File.expand_path('~'), '.cache', 'clio', "#{name}.yaml")
end