Class: Strongspace::Command::Help

Inherits:
Base show all
Defined in:
lib/strongspace/commands/help.rb

Defined Under Namespace

Classes: HelpGroup

Instance Attribute Summary

Attributes inherited from Base

#args

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize, #strongspace

Methods included from PluginInterface

#base_command, #command, included

Methods included from Helpers

#ask, #backup_space?, #bin_folder, #command_name, #computername, #confirm, #confirm_command, #create_pid_file, #credentials_file, #credentials_folder, #delete_pid_file, #display, #error, #format_date, #gui_ssh_key, home_directory, #home_directory, #kill_via_pidfile, #launchd_agents_folder, #logs_folder, #pid_file_path, #pid_from_pid_file, #pids_folder, #plugins_folder, #process_running?, #redisplay, running_on_a_mac?, #running_on_a_mac?, #running_on_windows?, running_on_windows?, #shell, #space_exist?, support_directory, #support_directory

Constructor Details

This class inherits a constructor from Strongspace::Command::Base

Class Method Details

.create_default_groups!Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/strongspace/commands/help.rb', line 31

def self.create_default_groups!
  group 'General Commands' do |group|
    group.command 'help',                         'show this usage'
    group.command 'version',                      'show the gem version'
    group.space
    group.command 'upload <local_path> <remote_path>',      'upload a file'
    group.command 'download <remote_path>',      'download a file from Strongspace to the current directory'
    group.command 'mkdir <remote_path>',      'create a folder on Strongspace'
    group.command 'delete <remote_path>',      'delete a file or recursively delete a folder on Strongspace'
  end

  group 'SSH Keys' do |group|
    group.command 'keys',                         'show your user\'s public keys'

    if not RUBY_PLATFORM =~ /mswin32|mingw32/
      group.command 'keys:add [<keyfile_path>]', 'Add an public key or generate a new SSH keypair and add'
      group.command 'keys:generate',                'Generate a new SSH keypair'
    else
      group.command 'keys:add [<keyfile_path>]', 'Add an public key'
    end

    group.command 'keys:remove <id> ',            'remove a key by id'
    group.command 'keys:clear',                   'remove all keys'
  end

  group 'Spaces' do |group|
    group.command 'spaces',                        'show your user\'s spaces'
    group.command 'spaces:create <name> [type]',        'add a new space. type => (normal,public,backup)'
    group.command 'spaces:delete <name> [type]',       'remove a space by and destroy its data'
    group.command 'spaces:snapshots <name>',                        'show a space\'s snapshots'
    group.command 'spaces:create_snapshot <name> [snapshot_name]',        'take a space of a space - snapshot_name defaults to current date/time.'
    group.command 'spaces:delete_snapshot <name> <snapshot_name>',         'remove a snapshot from a space'
  end

  group 'Plugins' do |group|
    group.command 'plugins',                      'list installed plugins'
    group.command 'plugins:install <url>',        'install the plugin from the specified git url'
    group.command 'plugins:uninstall <url/name>', 'remove the specified plugin'
  end

end

.group(title, &block) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/strongspace/commands/help.rb', line 23

def self.group(title, &block)
  groups << begin
    group = HelpGroup.new(title)
    yield group
    group
  end
end

.groupsObject



19
20
21
# File 'lib/strongspace/commands/help.rb', line 19

def self.groups
  @groups ||= []
end

Instance Method Details

#indexObject



75
76
77
# File 'lib/strongspace/commands/help.rb', line 75

def index
  display usage
end

#usageObject



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/strongspace/commands/help.rb', line 83

def usage
  longest_command_length = self.class.groups.map do |group|
    group.map { |g| g.first.length }
  end.flatten.max

  self.class.groups.inject(StringIO.new) do |output, group|
    output.puts "=== %s" % group.title

    group.each do |command, description|
      if command.empty?
        output.puts
      else
        output.puts "%-*s # %s" % [longest_command_length, command, description]
      end
    end

    output.puts
    output
  end.string
end

#versionObject



79
80
81
# File 'lib/strongspace/commands/help.rb', line 79

def version
  display Strongspace::Client.version
end