libis-tools 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3471bd7089b2059df27dd50e932a5d069fd81caa
4
- data.tar.gz: d361302b0cf5b1ebbbe489f6fb88b04a740955bb
3
+ metadata.gz: 5e609222120f658fb18e1594ed1f87f0c35bde28
4
+ data.tar.gz: 66d3563d04e59fd324a593754a74947b1c3a722f
5
5
  SHA512:
6
- metadata.gz: fdb901ba14397b93eec5157bb28b6ee0c39b0ecbb0e094b1b5a87a7e183338fb89ec2b0460b049035381179cc45f9c4661b1185c7f9a61b38085308546f69dea
7
- data.tar.gz: fa413bbcdc1349838b9cc8f6156b4fd52a7466ed382b3f98b47abd4f87fa0925eb8b010c951fea4cbec59b4e857435254f9624d9c50549f760d85b3c0bc6af2f
6
+ metadata.gz: ef95ab98cc37ab82f24e92f1db943cd92eef3276964c5ee3c2591aa1575dda048bd01c2d6117a230726f6a7d735d1fca8d0591c0c256c206e868b57663782eec
7
+ data.tar.gz: ab8ffbcec667aa8f6d618f2f5c3cbc5295a46bea69038f7c3e4616e465c3f01044b2cc22bddf1963f3dac96695135b773048bb46d4eb41a3570654a405450b67
@@ -35,7 +35,8 @@ module Libis
35
35
  overwrite: "Overwite target files if newer",
36
36
  interactive: "Ask for action on changed files",
37
37
  report: "Report file",
38
- dummy: "Perform phantom actions (not affecting files)"
38
+ dummy: "Perform phantom actions (not affecting files)",
39
+ config: "Load saved configuration parameters"
39
40
  }
40
41
 
41
42
  REQ_HEADERS = {term: 'Term'}
@@ -43,6 +44,10 @@ module Libis
43
44
 
44
45
  def self.included(klass)
45
46
  klass.class_exec do
47
+ def klass.description(field)
48
+ "#{STRING_CONFIG[field]}." + (DEFAULT_CONFIG[field].nil? ? '' : " default: #{DEFAULT_CONFIG[field]}")
49
+ end
50
+
46
51
  desc 'reorg [options]', 'Reorganize files'
47
52
  long_desc <<-DESC
48
53
 
@@ -94,33 +99,36 @@ module Libis
94
99
  before continuing of bailing out. If you are confident the settings are fine, you can skip this with the
95
100
  '--unatttended' option. Handle with care!
96
101
 
102
+ Unless you have specified the '--unattended' options, you will be presented with a menu that allows you to
103
+ change the configuration parameters, run the tool with the current config or bail out.
104
+
97
105
  DESC
98
106
 
99
- method_option :base, aliases: '-b', desc: 'Directory that needs to be reorganized',
100
- default: DEFAULT_CONFIG[:base]
101
- method_option :filter, aliases: '-f', desc: 'Regex for file name matching',
102
- default: DEFAULT_CONFIG[:filter]
103
- method_option :expression, aliases: '-e', desc: 'Ruby string expression for the new file path',
104
- default: DEFAULT_CONFIG[:expression]
107
+ method_option :base, aliases: '-b',
108
+ desc: description(:base)
109
+ method_option :filter, aliases: '-f',
110
+ desc: description(:filter)
111
+ method_option :expression, aliases: '-e',
112
+ desc: description(:expression)
105
113
 
106
- method_option :action, aliases: '-a', desc: 'Operation to perform on files found',
107
- enum: VALID_ACTIONS.keys, default: DEFAULT_CONFIG[:action]
108
- method_option :overwrite, aliases: '-o', desc: 'Overwrite target if changed',
109
- type: :boolean, default: DEFAULT_CONFIG[:overwrite]
110
- method_option :interactive, aliases: '-i', desc: 'Ask for action when changed files are found',
111
- type: :boolean, default: DEFAULT_CONFIG[:interactive]
114
+ method_option :action, aliases: '-a', enum: VALID_ACTIONS.keys,
115
+ desc: description(:action)
116
+ method_option :overwrite, aliases: '-o', type: :boolean,
117
+ desc: description(:overwrite)
118
+ method_option :interactive, aliases: '-i', type: :boolean,
119
+ desc: description(:interactive)
112
120
 
113
- method_option :report, aliases: '-r', banner: 'FILE', desc: 'Generate report in FILE',
114
- default: DEFAULT_CONFIG[:report]
121
+ method_option :report, aliases: '-r', banner: 'FILE',
122
+ desc: description(:report)
115
123
 
116
- method_option :dummy, desc: 'Do not perform file actions, only report them',
117
- type: :boolean, default: DEFAULT_CONFIG[:dummy]
124
+ method_option :dummy, aliases: '-d', type: :boolean,
125
+ desc: description(:dummy)
118
126
 
119
- method_option :config, aliases: '-c', desc: 'Configuration name to use',
120
- type: :string, default: DEFAULT_CONFIG[:config]
127
+ method_option :config, aliases: '-c', type: :string,
128
+ desc: description(:config)
121
129
 
122
- method_option :unattended, aliases: '-u', desc: 'Run without asking for input',
123
- type: :boolean, default: DEFAULT_CONFIG[:unattended]
130
+ method_option :unattended, aliases: '-u', type: :boolean,
131
+ desc: description(:unattended)
124
132
 
125
133
  end
126
134
 
@@ -131,10 +139,11 @@ module Libis
131
139
 
132
140
  # return config_write
133
141
 
134
- DEFAULT_CONFIG.each {|key, value| config.set(key, value: value) if value}
142
+ DEFAULT_CONFIG.each {|key, value| config.set(key, value: value) unless value.nil?}
135
143
  config_read(options[:config]) if options[:config]
136
- DEFAULT_CONFIG.each {|key, _| config.set(key, value: options[:key]) if options.has_key?(key)}
137
- run_menu
144
+ DEFAULT_CONFIG.each {|key, _| config.set(key, value: options[key]) if options.has_key?(key.to_s)}
145
+ run_menu unless options[:unattended]
146
+ do_reorg
138
147
  end
139
148
 
140
149
  protected
@@ -148,8 +157,8 @@ module Libis
148
157
  value: -> {config_menu; 1}
149
158
  }
150
159
 
151
- choices << {name: "Run", value: -> {do_reorg; nil}}
152
- choices << {name: "Exit", value: nil}
160
+ choices << {name: "Run", value: nil}
161
+ choices << {name: "Exit", value: -> {exit}}
153
162
 
154
163
  selection = prompt.select "[ LIBIS Tool - ReOrg ]",
155
164
  choices, cycle: true, default: 1
@@ -1,5 +1,5 @@
1
1
  module Libis
2
2
  module Tools
3
- VERSION = '1.0.1'
3
+ VERSION = '1.0.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libis-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kris Dekeyser