dtf 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,16 +1,16 @@
1
1
  # encoding: UTF-8
2
2
  # Reusable error response method
3
- def raise_error
3
+ def raise_error(cmd)
4
4
  raise ArgumentError
5
5
  rescue
6
- $stderr.puts "ERROR! #{@cmd} did not receive all required options."
7
- $stderr.puts "See 'dtf #{@cmd} -h' for help with this sub-command"
6
+ $stderr.puts "ERROR! #{cmd} did not receive all required options."
7
+ $stderr.puts "See 'dtf #{cmd} -h' for help with this sub-command"
8
8
 
9
9
  # Set non-zero exit value on error, for scripting use.
10
10
  abort()
11
11
  end
12
12
 
13
- def display_errors()
13
+ def display_errors(cmd)
14
14
  # TODO: Refactor error display to take sub-command as an arg
15
15
  # and display obj.errors.messages.each properly for each arg type.
16
16
  end
@@ -2,54 +2,58 @@
2
2
  # DTF Help System
3
3
  require 'trollop' # Used to implement help system
4
4
 
5
+ module Dtf::HelpSystem
6
+
7
+ # List of all sub-commands known within the Help System
5
8
  SUB_COMMANDS = %w(create_user delete_user create_vs delete_vs)
6
9
 
7
- # Global options default to '--version|-v' and '--help|-h'
8
- global_opts = Trollop::options do
9
- version "DTF v#{Dtf::VERSION}"
10
- banner <<-EOS
11
- #{version}
12
- (c) Copyright 2012 David Deryl Downey / Deryl R. Doucette. All Rights Reserved.
13
- This is free software; see the LICENSE file for copying conditions.
14
- There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
+ # Global options default to '--version|-v' and '--help|-h'
11
+ global_opts = Trollop::options do
12
+ version "DTF v#{Dtf::VERSION}"
13
+ banner <<-EOS
14
+ #{version}
15
+ (c) Copyright 2012 David Deryl Downey / Deryl R. Doucette. All Rights Reserved.
16
+ This is free software; see the LICENSE file for copying conditions.
17
+ There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
18
 
16
- Usage:
17
- dtf -v|--version -h|--help [[sub_cmds <options>] -h|--help]
19
+ Usage:
20
+ dtf -v|--version -h|--help [[sub_cmds <options>] -h|--help]
18
21
 
19
- Valid [sub_cmds] are: create_(user|vs), delete_(user|vs)
20
- See 'dtf [sub_cmd] -h' for each sub_cmd's details and options
22
+ Valid [sub_cmds] are: create_(user|vs), delete_(user|vs)
23
+ See 'dtf [sub_cmd] -h' for each sub_cmd's details and options
21
24
 
22
- EOS
23
- stop_on SUB_COMMANDS
24
- end
25
+ EOS
26
+ stop_on SUB_COMMANDS
27
+ end
25
28
 
26
- # Sub-commands go here
27
- @cmd = ARGV.shift
28
- @cmd_opts = case @cmd
29
- when "create_user"
30
- Trollop::options do
31
- opt(:user_name, desc="Username for new TF user - REQUIRED", opts={:type => :string, :short => '-u'})
32
- opt(:full_name, desc="Real name for new TF user - REQUIRED", opts={:type => :string, :short => '-n'})
33
- opt(:email_address, desc="Email address for new TF user - REQUIRED", opts={:type => :string, :short => '-e'})
34
- end
35
- when "create_vs"
36
- Trollop::options do
37
- opt(:user_name, desc="TF user to associate this VS with - REQUIRED", opts={:type => :string, :short => '-u'})
38
- opt(:name, desc="Name for new VS - REQUIRED", opts={:type => :string, :short => '-n'})
39
- opt(:description, desc="Description of VS's intended use - OPTIONAL", opts={:type => :string, :short => '-d', :default => ''})
40
- end
41
- when "delete_user"
42
- Trollop::options do
43
- opt(:user_name, desc="Username of TF user to delete - REQUIRED", opts={:type => :string, :short => '-u'})
44
- opt(:delete_all, desc="Delete _all_ VSs this user owns", :type => :flag, :default => true)
29
+ @cmd = ARGV.shift
30
+ @cmd_opts = case @cmd
31
+ when "create_user"
32
+ Trollop::options do
33
+ opt(:user_name, desc="Username for new TF user - REQUIRED", opts={:type => :string, :short => '-u'})
34
+ opt(:full_name, desc="Real name for new TF user - REQUIRED", opts={:type => :string, :short => '-n'})
35
+ opt(:email_address, desc="Email address for new TF user - REQUIRED", opts={:type => :string, :short => '-e'})
36
+ end
37
+ when "create_vs"
38
+ Trollop::options do
39
+ opt(:user_name, desc="TF user to associate this VS with - REQUIRED", opts={:type => :string, :short => '-u'})
40
+ opt(:name, desc="Name for new VS - REQUIRED", opts={:type => :string, :short => '-n'})
41
+ opt(:description, desc="Description of VS's intended use - OPTIONAL", opts={:type => :string, :short => '-d', :default => ''})
42
+ end
43
+ when "delete_user"
44
+ Trollop::options do
45
+ opt(:user_name, desc="Username of TF user to delete - REQUIRED", opts={:type => :string, :short => '-u'})
46
+ opt(:delete_all, desc="Delete _all_ VSs this user owns", :type => :flag, :default => true)
47
+ end
48
+ when "delete_vs"
49
+ Trollop::options do
50
+ opt(:user_name, desc="Username of VS owner - REQUIRED", opts={:type => :string, :short => '-u'})
51
+ opt(:id, desc="ID of VS to be deleted - REQUIRED", opts={:type => :int, :short => '-i'})
52
+ end
53
+ when nil
54
+ Trollop::die "No command specified! Please specify an applicable command"
55
+ else
56
+ Trollop::die "Unknown DTF sub-command: #{@cmd.inspect}"
45
57
  end
46
- when "delete_vs"
47
- Trollop::options do
48
- opt(:user_name, desc="Username of VS owner - REQUIRED", opts={:type => :string, :short => '-u'})
49
- opt(:id, desc="ID of VS to be deleted - REQUIRED", opts={:type => :int, :short => '-i'})
50
- end
51
- when nil
52
- Trollop::die "No command specified! Please specify an applicable command"
53
- else
54
- Trollop::die "Unknown DTF sub-command: #{@cmd.inspect}"
55
- end
58
+
59
+ end
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module Dtf
4
- VERSION = "0.2.6"
4
+ VERSION = "0.2.7"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dtf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-15 00:00:00.000000000 Z
12
+ date: 2012-09-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -302,7 +302,8 @@ files:
302
302
  - doc/AnalysisCase.html
303
303
  - doc/CaseTest.html
304
304
  - doc/Dtf.html
305
- - doc/Dtf/DtfCommands.html
305
+ - doc/Dtf/Command.html
306
+ - doc/Dtf/HelpSystem.html
306
307
  - doc/User.html
307
308
  - doc/VerificationSuite.html
308
309
  - doc/_index.html