cl-magic 0.3.1 → 0.3.3

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
  SHA256:
3
- metadata.gz: 80e53f5ff775b7ea5408b5d2e897ff5b5aa660c3e4bac1fcb2665299b8720d58
4
- data.tar.gz: 3548fc6ff4d1521bf7ce556e7308cc3c91a75ec79e0617c913ead953fc10348f
3
+ metadata.gz: '0999ba01e614cf06ee6743675a486597876ee648b5c8e659f0afb468918703bd'
4
+ data.tar.gz: e5ad4f67f7fe2f4ab75cdb31dbfb54dee39101482bf9fe482b67c3fc2fb3f14f
5
5
  SHA512:
6
- metadata.gz: 74e1d78d0a26c2cfab9c2ada3bb4ae2785494697845460beada56310f1759c0c1d3aaf4834956c030b9c7c15a13edd6a8100f99285bae4bd9699729e2973e848
7
- data.tar.gz: e7c3f76abb93e22048895e7b451c835c8048a6548a929db52c6c2ab7b9b10f6fddabe41f9641d9b09a7a39642a4e1f4461dab33f7f2352e68e9ef4b6d8a420ce
6
+ metadata.gz: 8c0d00d9e476d43a2178edb581965879cac36fb0cc70037850613371ebe639f0e2badffcd63b86986246f0348ed13458be29522304f5f81d65e22c54c4c0a113
7
+ data.tar.gz: 9a89994bc628eaf9fe5de592d989cc581bf0dfcbd645d5ab135d495a2c5cc47adcd30e8a32a0142a1367aaf765f55f202fb1545e29db313bd4439a29e2d54f5f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cl-magic (0.3.1)
4
+ cl-magic (0.3.3)
5
5
  optparse-subcommand
6
6
  pastel
7
7
  tty-command
data/lib/cl/magic/cl-dk CHANGED
@@ -151,16 +151,11 @@ def print_set_world_help()
151
151
  puts ""
152
152
  end
153
153
 
154
- def print_save_parts_help(dk_parts_hash)
154
+ def print_set_parts_help()
155
155
  puts ""
156
- puts "Usage: dk [DK_PARTS] save-parts"
156
+ puts "Usage: dk [DK_PARTS] set-parts"
157
157
  puts ""
158
- puts "Save parts in project and apply every time"
159
- puts ""
160
- puts "Parts:"
161
- dk_parts_hash.keys.each do |key|
162
- print_dk_help_line(key, dk_parts_hash[key].fetch('help'))
163
- end
158
+ puts "Set parts for a project and apply to every 'dk' command"
164
159
  puts ""
165
160
  end
166
161
 
@@ -327,7 +322,11 @@ def run_dk_set_world()
327
322
  print_set_world_help
328
323
  exit
329
324
  else
330
- world_path = File.expand_path(File.join(@working_dir, world_path))
325
+ if world_path.start_with?("/") or world_path.start_with?("~")
326
+ world_path = File.expand_path(world_path)
327
+ else
328
+ world_path = File.expand_path(File.join(@working_dir, world_path))
329
+ end
331
330
  end
332
331
 
333
332
  if TTY::Prompt.new.yes?("Set world to: #{world_path}?")
@@ -360,23 +359,25 @@ def run_dk_set_context()
360
359
  end
361
360
 
362
361
  #
363
- # Run: SAVE PARTS
362
+ # Run: SET PARTS
364
363
  #
365
364
 
366
- def run_dk_save_parts(compose_args, dk_parts_hash, selected_part_keys)
365
+ def run_dk_set_parts()
366
+ parts = ARGV[1..]
367
367
  filepath = get_save_parts_filepath()
368
- if selected_part_keys.any?
368
+ if parts.any?
369
369
  tempfile = File.new(filepath, 'w')
370
- tempfile.write(selected_part_keys.to_yaml) # write it to the tempfile
370
+ tempfile.write(ARGV[1..].to_yaml) # write it to the tempfile
371
371
  tempfile.close
372
372
  else
373
373
  if File.exist?(filepath)
374
374
  File.delete(filepath)
375
375
  @logger.info "parts cleared"
376
376
  else
377
- print_save_parts_help(dk_parts_hash)
377
+ print_set_parts_help()
378
378
  end
379
379
  end
380
+ exit
380
381
  end
381
382
 
382
383
  #
@@ -458,37 +459,38 @@ end
458
459
 
459
460
  @working_dir = ENV['CL_WORKING_DIR'] # passed through cl-magic to here
460
461
 
461
- # sub-command
462
+ # SET commands first
462
463
  case ARGV.first
463
464
  when "set-world"
464
465
  run_dk_set_world()
465
466
  when "set-context"
466
467
  run_dk_set_context()
467
- end
468
-
469
- # get compose settings
470
- compose_hash = get_base_compose_hash()
471
- if compose_hash
472
-
473
- # world
474
- compose_hash = merge_world_files(compose_hash, show_help=ARGV.include?("--help"))
475
-
476
- # x-dk fragments
477
- dk_parts_hash = compose_hash['x-dk-parts'] ? compose_hash.delete('x-dk-parts') : {}
478
- dk_make_hash = compose_hash['x-dk-make'] ? compose_hash.delete('x-dk-make') : {}
479
-
480
- # parts
481
- saved_part_keys = get_saved_parts(dk_parts_hash)
482
- compose_args, selected_part_keys = merge_parts_save_and_prep_args(compose_hash, dk_parts_hash, dk_make_hash, saved_part_keys)
483
-
484
- # sub-command
485
- case compose_args[2]
486
- when "make"
487
- all_part_keys = selected_part_keys + saved_part_keys
488
- run_dk_make(compose_args, dk_make_hash, dk_parts_hash, all_part_keys)
489
- when "save-parts"
490
- run_dk_save_parts(compose_args, dk_parts_hash, selected_part_keys)
491
- else
492
- run_dk(compose_args)
468
+ when "set-parts"
469
+ run_dk_set_parts()
470
+ else
471
+
472
+ # get compose settings
473
+ compose_hash = get_base_compose_hash()
474
+ if compose_hash
475
+
476
+ # world
477
+ compose_hash = merge_world_files(compose_hash, show_help=ARGV.include?("--help"))
478
+
479
+ # x-dk fragments
480
+ dk_parts_hash = compose_hash['x-dk-parts'] ? compose_hash.delete('x-dk-parts') : {}
481
+ dk_make_hash = compose_hash['x-dk-make'] ? compose_hash.delete('x-dk-make') : {}
482
+
483
+ # parts
484
+ saved_part_keys = get_saved_parts(dk_parts_hash)
485
+ compose_args, selected_part_keys = merge_parts_save_and_prep_args(compose_hash, dk_parts_hash, dk_make_hash, saved_part_keys)
486
+
487
+ # sub-command
488
+ case compose_args[2]
489
+ when "make"
490
+ all_part_keys = selected_part_keys + saved_part_keys
491
+ run_dk_make(compose_args, dk_make_hash, dk_parts_hash, all_part_keys)
492
+ else
493
+ run_dk(compose_args)
494
+ end
493
495
  end
494
496
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Cl
4
4
  module Magic
5
- VERSION = "0.3.1"
5
+ VERSION = "0.3.3"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cl-magic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Don Najd