Skip to content

Tag to permit option hash key-value to be set when flag encountered #4

Description

@mwsis

Rather than:

options = {}                                                                   
climate = LibCLImate::Climate.new do |cl|                                      
                                                                               
  cl.info_lines = [                                                            
    'Synesis Information Systems freelibs umbrella tools',                     
    :version,                                                                  
    'Conditionally creates or fetch-updates local SIS freelibs projects.',  
    nil,                                                                       
  ]                                                                            
                                                                               
  cl.add_flag('--clone-only', alias: '-c', help: 'Only clone missing projects; skip updates of existing checkouts') { options[:clone_only] = true }
  cl.add_flag('--dry-run', alias: '-d', help: 'Perform a dry run, without making any changes') { options[:dry_run] = true }
  cl.add_flag('--update-only', alias: '-u', help: 'Only update existing checkouts; skip cloning missing projects') { options[:update_only] = true }
                                                                               
  . . .
end                                                                            

then something along the lines of the following:

options = {}                                                                   
climate = LibCLImate::Climate.new(options) do |cl|                                      
                                                                               
  cl.info_lines = [                                                            
    'Synesis Information Systems freelibs umbrella tools',                     
    :version,                                                                  
    'Conditionally creates or fetch-updates local SIS freelibs projects.',  
    nil,                                                                       
  ]                                                                            
                                                                               
  cl.add_flag('--clone-only', alias: '-c', option_name: :clone_only, help: 'Only clone missing projects; skip updates of existing checkouts')
  cl.add_flag('--dry-run', alias: '-d', option_name: :dry_run, help: 'Perform a dry run, without making any changes')
  cl.add_flag('--update-only', alias: '-u', option_name: :update_only, help: 'Only update existing checkouts; skip cloning missing projects')
                                                                               
  . . .
end                                                                            

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions