cl-magic 1.2.9 → 1.2.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +16 -9
  3. data/README.md +6 -0
  4. data/bin/cl +1 -1
  5. data/bin/install_gem +4 -4
  6. data/cl-magic.gemspec +1 -1
  7. data/lib/cl/magic/cl +1 -1
  8. data/lib/cl/magic/cl-ai-chat +1 -2
  9. data/lib/cl/magic/cl-ai-query +1 -2
  10. data/lib/cl/magic/cl-ai-store-jira +1 -2
  11. data/lib/cl/magic/cl-auth +1 -2
  12. data/lib/cl/magic/cl-chrome +108 -0
  13. data/lib/cl/magic/cl-dk-make +1 -2
  14. data/lib/cl/magic/cl-dk-make-world +8 -18
  15. data/lib/cl/magic/cl-dk-parts +1 -2
  16. data/lib/cl/magic/cl-dk-world +1 -2
  17. data/lib/cl/magic/cl-envkey +1 -2
  18. data/lib/cl/magic/cl-gc-sql +1 -2
  19. data/lib/cl/magic/cl-gc-tags +1 -2
  20. data/lib/cl/magic/cl-glab-commit +1 -2
  21. data/lib/cl/magic/cl-history +1 -2
  22. data/lib/cl/magic/cl-jira-fetch +1 -2
  23. data/lib/cl/magic/cl-jira-fetch-by-epics +1 -2
  24. data/lib/cl/magic/cl-jira-to-elastic +1 -2
  25. data/lib/cl/magic/cl-jira-to-markdown +1 -2
  26. data/lib/cl/magic/cl-jira-to-stats +1 -2
  27. data/lib/cl/magic/cl-kube-cp +1 -2
  28. data/lib/cl/magic/cl-kube-deployment +1 -2
  29. data/lib/cl/magic/cl-kube-ktx +1 -2
  30. data/lib/cl/magic/cl-kube-logs +1 -2
  31. data/lib/cl/magic/cl-kube-restart +1 -2
  32. data/lib/cl/magic/cl-kube-search +1 -2
  33. data/lib/cl/magic/cl-kube-search-all +1 -2
  34. data/lib/cl/magic/cl-kube-ssh +1 -2
  35. data/lib/cl/magic/cl-poll +1 -2
  36. data/lib/cl/magic/cl-sandbox +1 -2
  37. data/lib/cl/magic/cl-vault +1 -2
  38. data/lib/cl/magic/common/sub_command.rb +51 -0
  39. data/lib/cl/magic/dk/world_settings.rb +18 -0
  40. data/lib/cl/magic/dk/yaml_arg_munger.rb +28 -0
  41. data/lib/cl/magic/version.rb +1 -1
  42. metadata +18 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6967402db7c32f3077e4ae254f3ac3654375440e41a66f8225d66fb204e1f8f5
4
- data.tar.gz: 88c12801db8a8a1a02f767e42e7eb8dd846b0da697faa052c9222e4abeeff2fb
3
+ metadata.gz: 2e26140cc95c280b62ba2fbdfba15bb2c76183ca1bab0abd27cd41489f9fe4fc
4
+ data.tar.gz: bb1e3783a4bddf51aff6f7b5e937095d0909f2a4c27f1973c02dfedbc0d2e1d3
5
5
  SHA512:
6
- metadata.gz: bf66f0485b1e40ac998168f9ae7420f5d0cd2a14ecc83b6f3336b045349efb2c098ac0c0d9e26e5bf7bebeeedec98e30ecd4901268b47e75df5b8892113a18eb
7
- data.tar.gz: 476128662c389749a19e557fc0ec334f392b0333983bf823b8f91d7e1d06d0bf20e15ba7112a60acc261c4121cb8e393fd3a6887bc39b82cbdaea891329be77e
6
+ metadata.gz: c66ec59e78d1a8d1c440740c43e605a5785e33300d436f454c436597e56aceeee88259c027936d6054f4e7cf97ceb913f1cff302b039daa626f8689a1ece3f42
7
+ data.tar.gz: ea004d5cc57a0b1a109eb7d64991185f21d6a66009318ec24fa0303a906a4dc8e497c73e595e2a672718c6e91110c4f9a583cb7bf690b0be6545bf9e0ad5a7c8
data/Gemfile.lock CHANGED
@@ -1,12 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cl-magic (1.2.9)
4
+ cl-magic (1.2.10)
5
5
  activesupport
6
6
  baran
7
7
  concurrent-ruby
8
- optparse-subcommand
9
8
  pastel
9
+ selenium-webdriver
10
10
  tty-command
11
11
  tty-logger
12
12
  tty-progressbar
@@ -16,21 +16,26 @@ PATH
16
16
  GEM
17
17
  remote: https://rubygems.org/
18
18
  specs:
19
- activesupport (7.0.7)
19
+ activesupport (7.0.8)
20
20
  concurrent-ruby (~> 1.0, >= 1.0.2)
21
21
  i18n (>= 1.6, < 2)
22
22
  minitest (>= 5.1)
23
23
  tzinfo (~> 2.0)
24
- baran (0.1.7)
24
+ baran (0.1.9)
25
25
  byebug (11.1.3)
26
26
  concurrent-ruby (1.2.2)
27
27
  i18n (1.14.1)
28
28
  concurrent-ruby (~> 1.0)
29
- minitest (5.18.0)
30
- optparse-subcommand (1.0.0)
29
+ minitest (5.20.0)
31
30
  pastel (0.8.0)
32
31
  tty-color (~> 0.5)
33
32
  rake (13.0.6)
33
+ rexml (3.2.6)
34
+ rubyzip (2.3.2)
35
+ selenium-webdriver (4.14.0)
36
+ rexml (~> 3.2, >= 3.2.5)
37
+ rubyzip (>= 1.2.2, < 3.0)
38
+ websocket (~> 1.0)
34
39
  strings-ansi (0.2.0)
35
40
  tty-color (0.6.0)
36
41
  tty-command (0.10.1)
@@ -55,11 +60,13 @@ GEM
55
60
  tty-cursor (~> 0.7)
56
61
  tzinfo (2.0.6)
57
62
  concurrent-ruby (~> 1.0)
58
- unicode-display_width (2.4.2)
63
+ unicode-display_width (2.5.0)
64
+ websocket (1.2.10)
59
65
  wisper (2.0.1)
60
66
 
61
67
  PLATFORMS
62
- ruby
68
+ arm64-darwin-22
69
+ x86_64-linux
63
70
 
64
71
  DEPENDENCIES
65
72
  byebug
@@ -68,4 +75,4 @@ DEPENDENCIES
68
75
  rake (~> 13.0)
69
76
 
70
77
  BUNDLED WITH
71
- 2.1.4
78
+ 2.3.7
data/README.md CHANGED
@@ -35,3 +35,9 @@ Then sim-link to your cl-magic source code's bin script
35
35
  ```
36
36
  ln -s $(pwd)/bin/cl /usr/local/bin
37
37
  ```
38
+
39
+ if using `dk make-world`, you'll need to reset your world path
40
+
41
+ ```
42
+ dk world set --path ./dk-world
43
+ ```
data/bin/cl CHANGED
@@ -14,4 +14,4 @@ MAGIC_DIR="$( cd -P "$( dirname "$SOURCE" )/../lib/cl/magic" >/dev/null 2>&1 &&
14
14
 
15
15
  # make magic - with the correct version of ruby & the bundle
16
16
  cd $MAGIC_DIR
17
- RBENV_VERSION=2.7.5 CL_WORKING_DIR=$CL_WORKING_DIR bundle exec cl $@
17
+ RBENV_VERSION=3.1.2 CL_WORKING_DIR=$CL_WORKING_DIR bundle exec cl $@
data/bin/install_gem CHANGED
@@ -6,14 +6,14 @@ set -euo pipefail
6
6
  #
7
7
 
8
8
  has_ruby=$(ruby -v)
9
- if [[ $has_ruby != *"2.7.5"* ]]; then
9
+ if [[ $has_ruby != *"3.1.2"* ]]; then
10
10
  echo ""
11
- echo "(missing) ruby 2.7.5"
12
- echo "Please install ruby 2.7.5"
11
+ echo "(missing) ruby 3.1.2"
12
+ echo "Please install ruby 3.1.2"
13
13
  exit 1
14
14
  else
15
15
  echo ""
16
- echo "✅ Ruby 2.7.5"
16
+ echo "✅ Ruby 3.1.2"
17
17
  fi
18
18
 
19
19
  #
data/cl-magic.gemspec CHANGED
@@ -29,7 +29,6 @@ Gem::Specification.new do |spec|
29
29
 
30
30
  # dependencies
31
31
  spec.add_development_dependency "rake"
32
- spec.add_dependency "optparse-subcommand"
33
32
  spec.add_dependency "tty-logger"
34
33
  spec.add_dependency "tty-command"
35
34
  spec.add_dependency "tty-prompt"
@@ -39,6 +38,7 @@ Gem::Specification.new do |spec|
39
38
  spec.add_dependency "pastel"
40
39
  spec.add_dependency "activesupport"
41
40
  spec.add_dependency "baran"
41
+ spec.add_dependency "selenium-webdriver"
42
42
 
43
43
  spec.add_development_dependency "byebug"
44
44
 
data/lib/cl/magic/cl CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
- require 'optparse'
3
2
  require 'tty-command'
4
3
  require 'cl/magic/common/logging.rb'
4
+ require 'cl/magic/common/sub_command.rb'
5
5
 
6
6
  @logger = get_logger()
7
7
 
@@ -1,10 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Call open ai chat api
3
- require 'optparse'
4
- require 'optparse/subcommand'
5
3
  require 'tty-command'
6
4
  require 'tty-prompt'
7
5
 
6
+ require 'cl/magic/common/sub_command.rb'
8
7
  require 'cl/magic/common/common_options.rb'
9
8
  require 'cl/magic/common/logging.rb'
10
9
  require 'cl/magic/common/ai_prompt.rb'
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Prompt for similar content
3
- require 'optparse'
4
- require 'optparse/subcommand'
5
3
  require 'tty-command'
6
4
  require 'tty-prompt'
7
5
 
@@ -11,6 +9,7 @@ require 'cl/magic/common/jira.rb'
11
9
  require 'cl/magic/common/ai_prompt.rb'
12
10
  require 'cl/magic/common/milvus.rb'
13
11
  require 'cl/magic/common/elastic.rb'
12
+ require 'cl/magic/common/sub_command.rb'
14
13
 
15
14
  @logger = get_logger()
16
15
 
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Store jira json for AI
3
- require 'optparse'
4
- require 'optparse/subcommand'
5
3
  require 'tty-command'
6
4
  require 'tty-prompt'
7
5
 
@@ -11,6 +9,7 @@ require 'cl/magic/common/jira.rb'
11
9
  require 'cl/magic/common/ai_prompt.rb'
12
10
  require 'cl/magic/common/milvus.rb'
13
11
  require 'cl/magic/common/elastic.rb'
12
+ require 'cl/magic/common/sub_command.rb'
14
13
 
15
14
  @logger = get_logger()
16
15
 
data/lib/cl/magic/cl-auth CHANGED
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Need to authenticate? Check here first
3
- require 'optparse'
4
- require 'optparse/subcommand'
5
3
  require 'tty-command'
6
4
  require 'tty-prompt'
7
5
 
@@ -9,6 +7,7 @@ require 'cl/magic/common/common_options.rb'
9
7
  require 'cl/magic/common/logging.rb'
10
8
  require 'cl/magic/common/gcloud.rb'
11
9
  require 'cl/magic/common/kubectl.rb'
10
+ require 'cl/magic/common/sub_command.rb'
12
11
 
13
12
  @logger = get_logger()
14
13
  @cl_cmd_name = "cl auth"
@@ -0,0 +1,108 @@
1
+ #!/usr/bin/env ruby
2
+ # Request a page with the chrome browser
3
+ require 'tty-command'
4
+ require 'tty-prompt'
5
+
6
+ require 'cl/magic/common/common_options.rb'
7
+ require 'cl/magic/common/logging.rb'
8
+ require 'cl/magic/common/gcloud.rb'
9
+ require 'cl/magic/common/kubectl.rb'
10
+ require 'cl/magic/common/sub_command.rb'
11
+
12
+ require 'selenium-webdriver'
13
+
14
+ @logger = get_logger()
15
+ @cl_cmd_name = File.basename(__FILE__).split('-').join(' ')
16
+
17
+ #
18
+ # Features
19
+ #
20
+
21
+ def do_work(options)
22
+ @logger.info "start #{Time.now.strftime("%H:%M:%S")}"
23
+ concurrent = options[:concurrent]
24
+
25
+ begin
26
+
27
+ # create drivers
28
+ drivers = []
29
+ concurrent.times { drivers << Selenium::WebDriver.for(:chrome) }
30
+
31
+ # browse pages
32
+ options[:ids].each_slice(concurrent) do |ids|
33
+ ids.each_with_index do |id, i|
34
+ drivers[i].navigate.to URI.join(options[:uri], id)
35
+ end
36
+ sleep options[:sleep]
37
+ end
38
+
39
+ ensure
40
+ drivers.each {|d| d.quit }
41
+ end
42
+ @logger.info "end #{Time.now.strftime("%H:%M:%S")}"
43
+ end
44
+
45
+ #
46
+ # Options
47
+ #
48
+
49
+ options = {
50
+ concurrent: 1,
51
+ sleep: 0.1
52
+ }
53
+ global_banner = <<DOC
54
+
55
+ A sandbox to try things
56
+
57
+ Usage: #{@cl_cmd_name} [options]
58
+
59
+ DOC
60
+
61
+ global = OptionParser.new do |g|
62
+ g.banner = global_banner
63
+ add_help_and_verbose(g)
64
+
65
+ g.on("--base-uri URI", "uri to attach identifier to and browse") do |v|
66
+ options[:uri] = v
67
+ end
68
+
69
+ g.on("--ids CSV", "comma separated list of ids") do |v|
70
+ options[:ids] = v.split(',')
71
+ end
72
+
73
+ g.on("-c", "--concurrent NUMBER", "number of concurrent chromes to open (default: 1)") do |v|
74
+ options[:concurrent] = v.to_i
75
+ end
76
+
77
+ g.on("-s", "--sleep NUMBER", "number of seconds to sleep after opening page (default: 0.1)") do |v|
78
+ options[:sleep] = v.to_f
79
+ end
80
+ end
81
+
82
+ #
83
+ # Run
84
+ #
85
+
86
+ @working_dir = ENV['CL_WORKING_DIR'] # passed through cl-magic to here
87
+ global.parse(ARGV)
88
+
89
+
90
+ if options[:uri].nil?
91
+ @logger.error "missing --base-uri"
92
+ exit
93
+ end
94
+ if options[:ids].nil?
95
+ @logger.error "missing --ids"
96
+ exit
97
+ end
98
+
99
+
100
+ # display full command
101
+ write_history("""#{@cl_cmd_name} \\
102
+ --base-uri='#{options[:uri]}' \\
103
+ --ids=#{options[:ids].join(',')} \\
104
+ --sleep=#{options[:sleep]} \\
105
+ --concurrent=#{options[:concurrent]}
106
+ """)
107
+
108
+ do_work(options)
@@ -1,10 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
  # cli for your compose projects
3
- require 'optparse'
4
- require 'optparse/subcommand'
5
3
 
6
4
  require 'cl/magic/common/common_options.rb'
7
5
  require 'cl/magic/common/logging.rb'
6
+ require 'cl/magic/common/sub_command.rb'
8
7
 
9
8
  require_relative 'dk/help_printer'
10
9
  require_relative 'dk/yaml_arg_munger'
@@ -1,12 +1,12 @@
1
+
1
2
  #!/usr/bin/env ruby
2
3
  # cli for your world
3
4
  require 'yaml'
4
- require 'optparse'
5
- require 'optparse/subcommand'
6
5
  require 'tty-command'
7
6
 
8
7
  require 'cl/magic/common/common_options.rb'
9
8
  require 'cl/magic/common/logging.rb'
9
+ require 'cl/magic/common/sub_command.rb'
10
10
 
11
11
  require_relative 'dk/help_printer'
12
12
  require_relative 'dk/world_settings'
@@ -102,29 +102,19 @@ end
102
102
  #
103
103
 
104
104
  def do_work()
105
-
106
- # world yaml
107
- world_yaml_filepath = File.join(@world_path, "world.yml")
108
- if File.exist?(world_yaml_filepath)
109
-
110
- # read file, replace & yaml load
111
- contents = File.read(world_yaml_filepath)
112
- contents.gsub!('<dk-working-path>', @working_dir)
113
- yml_hash = YAML.load(contents)
114
-
115
- # run command
116
- if yml_hash and yml_hash.key? "x-dk-make-world"
105
+ yml_hash = @world_settings.get_world_yml_hash()
106
+ if yml_hash
107
+ if yml_hash.key? "x-dk-make-world"
117
108
  run_dk_make(ARGV, yml_hash["x-dk-make-world"])
118
109
  else
119
110
  @logger.puts ""
120
- @logger.warn "no commands available"
121
- @logger.info "#{world_yaml_filepath}"
111
+ @logger.warn "missing: x-dk-make-world in world.yml"
122
112
  @logger.puts ""
123
113
  end
124
114
  else
125
115
  @logger.puts ""
126
- @logger.warn "Current world context has no world.yml"
127
- @logger.info "#{world_path}"
116
+ @logger.warn "missing: world.yml"
117
+ @logger.info "#{@world_path}"
128
118
  @logger.puts ""
129
119
  end
130
120
  end
@@ -1,13 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
2
  # set, list and clear parts for a compose project
3
3
  require 'yaml'
4
- require 'optparse'
5
- require 'optparse/subcommand'
6
4
  require 'tty-command'
7
5
 
8
6
  require 'cl/magic/common/common_options.rb'
9
7
  require 'cl/magic/common/logging.rb'
10
8
  require 'cl/magic/common/parse_and_pick.rb'
9
+ require 'cl/magic/common/sub_command.rb'
11
10
 
12
11
  require_relative 'dk/help_printer'
13
12
  require_relative 'dk/yaml_arg_munger'
@@ -1,13 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
2
  # set world and context for dk tool
3
3
  require 'yaml'
4
- require 'optparse'
5
- require 'optparse/subcommand'
6
4
  require 'tty-command'
7
5
 
8
6
  require 'cl/magic/common/common_options.rb'
9
7
  require 'cl/magic/common/parse_and_pick.rb'
10
8
  require 'cl/magic/common/logging.rb'
9
+ require 'cl/magic/common/sub_command.rb'
11
10
 
12
11
  require_relative 'dk/world_settings'
13
12
 
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Human readable envkeys
3
- require 'optparse'
4
- require 'optparse/subcommand'
5
3
  require 'tty-command'
6
4
  require 'tty-prompt'
7
5
 
@@ -9,6 +7,7 @@ require 'cl/magic/common/common_options.rb'
9
7
  require 'cl/magic/common/logging.rb'
10
8
  require 'cl/magic/common/gcloud.rb'
11
9
  require 'cl/magic/common/kubectl.rb'
10
+ require 'cl/magic/common/sub_command.rb'
12
11
 
13
12
  @logger = get_logger()
14
13
  @cl_cmd_name = File.basename(__FILE__).split('-').join(' ')
@@ -1,13 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Connect to google cloud sql instance
3
- require 'optparse'
4
- require 'optparse/subcommand'
5
3
  require 'tty-command'
6
4
  require 'tty-prompt'
7
5
 
8
6
  require 'cl/magic/common/common_options.rb'
9
7
  require 'cl/magic/common/logging.rb'
10
8
  require 'cl/magic/common/gcloud.rb'
9
+ require 'cl/magic/common/sub_command.rb'
11
10
 
12
11
  @logger = get_logger()
13
12
  @cl_cmd_name = File.basename(__FILE__).split('-').join(' ')
@@ -1,13 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Work with gcloud docker image tags
3
- require 'optparse'
4
- require 'optparse/subcommand'
5
3
  require 'tty-command'
6
4
 
7
5
  require 'cl/magic/common/common_options.rb'
8
6
  require 'cl/magic/common/logging.rb'
9
7
  require 'cl/magic/common/gcloud.rb'
10
8
  require 'cl/magic/common/kubectl.rb'
9
+ require 'cl/magic/common/sub_command.rb'
11
10
 
12
11
  @logger = get_logger()
13
12
  @cl_cmd_name = File.basename(__FILE__).split('-').join(' ')
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Find a commit and open in a browser
3
- require 'optparse'
4
- require 'optparse/subcommand'
5
3
  require 'tty-command'
6
4
  require 'tty-prompt'
7
5
 
@@ -9,6 +7,7 @@ require 'cl/magic/common/common_options.rb'
9
7
  require 'cl/magic/common/logging.rb'
10
8
  require 'cl/magic/common/gcloud.rb'
11
9
  require 'cl/magic/common/kubectl.rb'
10
+ require 'cl/magic/common/sub_command.rb'
12
11
 
13
12
  @logger = get_logger()
14
13
  @cl_cmd_name = File.basename(__FILE__).split('-').join(' ')
@@ -1,11 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
  # History of 'cl' commands you run
3
- require 'optparse'
4
- require 'optparse/subcommand'
5
3
  require 'tty-command'
6
4
 
7
5
  require 'cl/magic/common/common_options.rb'
8
6
  require 'cl/magic/common/logging.rb'
7
+ require 'cl/magic/common/sub_command.rb'
9
8
 
10
9
  @logger = get_logger()
11
10
  @cl_cmd_name = File.basename(__FILE__).split('-').join(' ')
@@ -1,13 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Fetch jira issues by jql
3
- require 'optparse'
4
- require 'optparse/subcommand'
5
3
  require 'tty-command'
6
4
  require 'tty-prompt'
7
5
 
8
6
  require 'cl/magic/common/common_options.rb'
9
7
  require 'cl/magic/common/logging.rb'
10
8
  require 'cl/magic/common/jira.rb'
9
+ require 'cl/magic/common/sub_command.rb'
11
10
 
12
11
  require 'net/http'
13
12
  require 'json'
@@ -1,13 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Fetch jira issues, status changelogs and save them to a file
3
- require 'optparse'
4
- require 'optparse/subcommand'
5
3
  require 'tty-command'
6
4
  require 'tty-prompt'
7
5
 
8
6
  require 'cl/magic/common/common_options.rb'
9
7
  require 'cl/magic/common/logging.rb'
10
8
  require 'cl/magic/common/jira.rb'
9
+ require 'cl/magic/common/sub_command.rb'
11
10
 
12
11
  require 'net/http'
13
12
  require 'json'
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Jira fetch datafile to markdown
3
- require 'optparse'
4
- require 'optparse/subcommand'
5
3
  require 'tty-command'
6
4
  require 'tty-prompt'
7
5
  require 'active_support/all'
@@ -10,6 +8,7 @@ require 'cl/magic/common/parse_and_pick.rb'
10
8
  require 'cl/magic/common/common_options.rb'
11
9
  require 'cl/magic/common/logging.rb'
12
10
  require 'cl/magic/common/jira.rb'
11
+ require 'cl/magic/common/sub_command.rb'
13
12
 
14
13
  require 'json'
15
14
 
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Jira fetch datafile to markdown
3
- require 'optparse'
4
- require 'optparse/subcommand'
5
3
  require 'tty-command'
6
4
  require 'tty-prompt'
7
5
  require 'active_support/all'
@@ -10,6 +8,7 @@ require 'cl/magic/common/parse_and_pick.rb'
10
8
  require 'cl/magic/common/common_options.rb'
11
9
  require 'cl/magic/common/logging.rb'
12
10
  require 'cl/magic/common/jira.rb'
11
+ require 'cl/magic/common/sub_command.rb'
13
12
 
14
13
  require 'json'
15
14
 
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Jira fetch datafile to stats
3
- require 'optparse'
4
- require 'optparse/subcommand'
5
3
  require 'tty-command'
6
4
  require 'tty-prompt'
7
5
  require 'active_support/all'
@@ -9,6 +7,7 @@ require 'active_support/all'
9
7
  require 'cl/magic/common/common_options.rb'
10
8
  require 'cl/magic/common/logging.rb'
11
9
  require 'cl/magic/common/jira.rb'
10
+ require 'cl/magic/common/sub_command.rb'
12
11
 
13
12
  require 'net/http'
14
13
  require 'json'
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Copy a file to a container in K8
3
- require 'optparse'
4
- require 'optparse/subcommand'
5
3
  require 'tty-command'
6
4
  require 'tty-prompt'
7
5
 
@@ -9,6 +7,7 @@ require 'cl/magic/common/common_options.rb'
9
7
  require 'cl/magic/common/logging.rb'
10
8
  require 'cl/magic/common/gcloud.rb'
11
9
  require 'cl/magic/common/kubectl.rb'
10
+ require 'cl/magic/common/sub_command.rb'
12
11
 
13
12
  @logger = get_logger()
14
13
  @cl_cmd_name = File.basename(__FILE__).split('-').join(' ')
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Find deployment in K8 and describe it
3
- require 'optparse'
4
- require 'optparse/subcommand'
5
3
  require 'tty-command'
6
4
  require 'tty-prompt'
7
5
  require 'json'
@@ -10,6 +8,7 @@ require 'pastel'
10
8
  require 'cl/magic/common/common_options.rb'
11
9
  require 'cl/magic/common/logging.rb'
12
10
  require 'cl/magic/common/kubectl.rb'
11
+ require 'cl/magic/common/sub_command.rb'
13
12
 
14
13
  @logger = get_logger()
15
14
  @cl_cmd_name = File.basename(__FILE__).split('-').join(' ')
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Find/save K8 cluster & namespace;then '--ktx' other kube commands
3
- require 'optparse'
4
- require 'optparse/subcommand'
5
3
  require 'tty-command'
6
4
  require 'tty-prompt'
7
5
  require 'json'
@@ -10,6 +8,7 @@ require 'pastel'
10
8
  require 'cl/magic/common/common_options.rb'
11
9
  require 'cl/magic/common/logging.rb'
12
10
  require 'cl/magic/common/kubectl.rb'
11
+ require 'cl/magic/common/sub_command.rb'
13
12
 
14
13
  @logger = get_logger()
15
14
  @cl_cmd_name = File.basename(__FILE__).split('-').join(' ')
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Find pods in k8 and follow the logs
3
- require 'optparse'
4
- require 'optparse/subcommand'
5
3
  require 'tty-command'
6
4
  require 'tty-prompt'
7
5
 
@@ -9,6 +7,7 @@ require 'cl/magic/common/common_options.rb'
9
7
  require 'cl/magic/common/logging.rb'
10
8
  require 'cl/magic/common/gcloud.rb'
11
9
  require 'cl/magic/common/kubectl.rb'
10
+ require 'cl/magic/common/sub_command.rb'
12
11
 
13
12
  @logger = get_logger()
14
13
  @cl_cmd_name = File.basename(__FILE__).split('-').join(' ')
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Find K8 deployment and reboot pods
3
- require 'optparse'
4
- require 'optparse/subcommand'
5
3
  require 'tty-command'
6
4
  require 'tty-prompt'
7
5
 
@@ -9,6 +7,7 @@ require 'cl/magic/common/common_options.rb'
9
7
  require 'cl/magic/common/logging.rb'
10
8
  require 'cl/magic/common/gcloud.rb'
11
9
  require 'cl/magic/common/kubectl.rb'
10
+ require 'cl/magic/common/sub_command.rb'
12
11
 
13
12
  @logger = get_logger()
14
13
  @cl_cmd_name = File.basename(__FILE__).split('-').join(' ')
@@ -1,12 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Search resources in k8 and list them;then select one to describe it
3
- require 'optparse'
4
- require 'optparse/subcommand'
5
3
  require 'tty-command'
6
4
 
7
5
  require 'cl/magic/common/common_options.rb'
8
6
  require 'cl/magic/common/logging.rb'
9
7
  require 'cl/magic/common/kubectl.rb'
8
+ require 'cl/magic/common/sub_command.rb'
10
9
 
11
10
  @logger = get_logger()
12
11
  @cl_cmd_name = File.basename(__FILE__).split('-').join(' ')
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Same as search, but across all clusters
3
- require 'optparse'
4
- require 'optparse/subcommand'
5
3
  require 'tty-command'
6
4
  require 'tty-prompt'
7
5
  require 'json'
@@ -10,6 +8,7 @@ require 'pastel'
10
8
  require 'cl/magic/common/common_options.rb'
11
9
  require 'cl/magic/common/logging.rb'
12
10
  require 'cl/magic/common/kubectl.rb'
11
+ require 'cl/magic/common/sub_command.rb'
13
12
 
14
13
  @logger = get_logger()
15
14
  @cl_cmd_name = File.basename(__FILE__).split('-').join(' ')
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Find container in k8 and ssh into it
3
- require 'optparse'
4
- require 'optparse/subcommand'
5
3
  require 'tty-command'
6
4
  require 'tty-prompt'
7
5
  require 'json'
@@ -10,6 +8,7 @@ require 'pastel'
10
8
  require 'cl/magic/common/common_options.rb'
11
9
  require 'cl/magic/common/logging.rb'
12
10
  require 'cl/magic/common/kubectl.rb'
11
+ require 'cl/magic/common/sub_command.rb'
13
12
 
14
13
  @logger = get_logger()
15
14
  @cl_cmd_name = File.basename(__FILE__).split('-').join(' ')
data/lib/cl/magic/cl-poll CHANGED
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Run any command every second
3
- require 'optparse'
4
- require 'optparse/subcommand'
5
3
  require 'tty-command'
6
4
  require 'tty-prompt'
7
5
 
@@ -9,6 +7,7 @@ require 'cl/magic/common/common_options.rb'
9
7
  require 'cl/magic/common/logging.rb'
10
8
  require 'cl/magic/common/gcloud.rb'
11
9
  require 'cl/magic/common/kubectl.rb'
10
+ require 'cl/magic/common/sub_command.rb'
12
11
 
13
12
  @logger = get_logger()
14
13
  @cl_cmd_name = File.basename(__FILE__).split('-').join(' ')
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Where cl commands are made
3
- require 'optparse'
4
- require 'optparse/subcommand'
5
3
  require 'tty-command'
6
4
  require 'tty-prompt'
7
5
 
@@ -9,6 +7,7 @@ require 'cl/magic/common/common_options.rb'
9
7
  require 'cl/magic/common/logging.rb'
10
8
  require 'cl/magic/common/gcloud.rb'
11
9
  require 'cl/magic/common/kubectl.rb'
10
+ require 'cl/magic/common/sub_command.rb'
12
11
 
13
12
  @logger = get_logger()
14
13
  @cl_cmd_name = File.basename(__FILE__).split('-').join(' ')
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Explore HashiCorp vault
3
- require 'optparse'
4
- require 'optparse/subcommand'
5
3
  require 'tty-command'
6
4
  require 'tty-prompt'
7
5
 
@@ -9,6 +7,7 @@ require 'cl/magic/common/common_options.rb'
9
7
  require 'cl/magic/common/logging.rb'
10
8
  require 'cl/magic/common/gcloud.rb'
11
9
  require 'cl/magic/common/kubectl.rb'
10
+ require 'cl/magic/common/sub_command.rb'
12
11
 
13
12
  @logger = get_logger()
14
13
  @cl_cmd_name = File.basename(__FILE__).split('-').join(' ')
@@ -0,0 +1,51 @@
1
+ require 'optparse'
2
+
3
+ OptionParser.send(:alias_method, :summarize_without_subcommand, :summarize)
4
+
5
+ class OptionParser
6
+ module Subcommand
7
+ def subcommand(key, &block)
8
+ subcommand = lambda { OptionParser.new(&block) }
9
+ subcommands[key.to_s] = subcommand
10
+ end
11
+
12
+ private
13
+
14
+ def parse_with_subcommand!(*args)
15
+ subcommand = catch(:subcommand) do
16
+ args.delete({:into=>nil}) # lose the {:into=>nil}
17
+ return order!(*args) { |sub| throw :subcommand, sub }
18
+ end
19
+
20
+ sub_parser = subcommands[subcommand.to_s]
21
+ if sub_parser
22
+ sub_parser.call.send(:parse!, *args)
23
+ end
24
+ end
25
+
26
+ def summarize_with_subcommand(to = [], width = @summary_width, max = width - 1, indent = @summary_indent, &blk)
27
+ summarize_without_subcommand(to, width, max, indent, &blk)
28
+ to << "\n"
29
+ subcommands.each do |key, sub_parser|
30
+ to << indent + key + "\n"
31
+ sub_parser.call.send(:summarize, to, width, max, indent + " ", &blk)
32
+ end
33
+ to
34
+ end
35
+
36
+ def subcommands
37
+ @subcommands ||= {}
38
+ end
39
+ end
40
+
41
+ include Subcommand
42
+
43
+ def parse!(*args)
44
+ parse_with_subcommand!(*args)
45
+ self
46
+ end
47
+
48
+ def summarize(to = [], width = @summary_width, max = width - 1, indent = @summary_indent, &blk)
49
+ summarize_with_subcommand(to, width, max, indent, &blk)
50
+ end
51
+ end
@@ -7,6 +7,24 @@ class WorldSettings
7
7
  @working_dir = working_dir
8
8
  end
9
9
 
10
+ #
11
+ # world yaml
12
+ #
13
+
14
+ def get_world_yml_hash()
15
+ yaml_filepath = File.join(self.get_world_path_from_settings, "world.yml")
16
+ if File.exist?(yaml_filepath)
17
+ contents = File.read(yaml_filepath)
18
+ contents.gsub!('<dk-working-path>', @working_dir)
19
+ return YAML.load(contents)
20
+ end
21
+ return nil
22
+ end
23
+
24
+ #
25
+ # world settings
26
+ #
27
+
10
28
  def get_world_settings_hash()
11
29
  filepath = get_world_settings_filepath()
12
30
  return File.exist?(filepath) ? YAML.load_file(filepath) : {}
@@ -50,6 +50,8 @@ class YamlArgMunger
50
50
  def get_base_compose_hash()
51
51
  cmd = "cd #{@working_dir} && docker compose config 2> /dev/null"
52
52
  hash = YAML.load(`#{cmd}`)
53
+ hotfix_environment_array(hash)
54
+
53
55
  return hash ? hash : {}
54
56
  end
55
57
 
@@ -75,12 +77,38 @@ class YamlArgMunger
75
77
 
76
78
  # yml merge
77
79
  yml_hash = YAML.load(contents)
80
+ hotfix_environment_array(yml_hash)
78
81
  compose_hash = dk_merge_and_remove(compose_hash, yml_hash)
79
82
  end
80
83
  end
81
84
  return compose_hash
82
85
  end
83
86
 
87
+ #
88
+ # docker compose config - converts 'environment' into an object
89
+ # and that messes up munging. So we are reversing that
90
+ #
91
+
92
+ def hotfix_environment_array(h)
93
+ stack = [h]
94
+ while stack.any?
95
+ ch = stack.pop
96
+ ch.each do |key, value|
97
+ if key.to_s == "environment"
98
+ if value.is_a?(Hash)
99
+ ch[key] = value.map { |k, v| "#{k}=#{v}" }
100
+ end
101
+ elsif value.is_a?(Hash)
102
+ stack.push(value)
103
+ end
104
+ end
105
+ end
106
+ end
107
+
108
+ #
109
+ # our dk hash merging process
110
+ #
111
+
84
112
  class ::Hash
85
113
  def dk_merge(second)
86
114
  merger = proc { |_, v1, v2|
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Cl
4
4
  module Magic
5
- VERSION = "1.2.9"
5
+ VERSION = "1.2.10"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cl-magic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.9
4
+ version: 1.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Don Najd
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-26 00:00:00.000000000 Z
11
+ date: 2024-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: optparse-subcommand
28
+ name: tty-logger
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: tty-logger
42
+ name: tty-command
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: tty-command
56
+ name: tty-prompt
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: tty-prompt
70
+ name: tty-spinner
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: tty-spinner
84
+ name: tty-progressbar
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: tty-progressbar
98
+ name: concurrent-ruby
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -109,7 +109,7 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: concurrent-ruby
112
+ name: pastel
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
@@ -123,7 +123,7 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: pastel
126
+ name: activesupport
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
@@ -137,7 +137,7 @@ dependencies:
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
- name: activesupport
140
+ name: baran
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - ">="
@@ -151,7 +151,7 @@ dependencies:
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
- name: baran
154
+ name: selenium-webdriver
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - ">="
@@ -199,6 +199,7 @@ files:
199
199
  - lib/cl/magic/cl-ai-query
200
200
  - lib/cl/magic/cl-ai-store-jira
201
201
  - lib/cl/magic/cl-auth
202
+ - lib/cl/magic/cl-chrome
202
203
  - lib/cl/magic/cl-dk
203
204
  - lib/cl/magic/cl-dk-make
204
205
  - lib/cl/magic/cl-dk-make-world
@@ -235,6 +236,7 @@ files:
235
236
  - lib/cl/magic/common/logging.rb
236
237
  - lib/cl/magic/common/milvus.rb
237
238
  - lib/cl/magic/common/parse_and_pick.rb
239
+ - lib/cl/magic/common/sub_command.rb
238
240
  - lib/cl/magic/dk/help_printer.rb
239
241
  - lib/cl/magic/dk/parts_merger.rb
240
242
  - lib/cl/magic/dk/world_settings.rb
@@ -248,7 +250,7 @@ metadata:
248
250
  homepage_uri: https://gitlab.com/beesbot/cl-magic
249
251
  source_code_uri: https://gitlab.com/beesbot/cl-magic
250
252
  changelog_uri: https://gitlab.com/beesbot/cl-magic
251
- post_install_message:
253
+ post_install_message:
252
254
  rdoc_options: []
253
255
  require_paths:
254
256
  - lib
@@ -263,8 +265,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
263
265
  - !ruby/object:Gem::Version
264
266
  version: '0'
265
267
  requirements: []
266
- rubygems_version: 3.1.6
267
- signing_key:
268
+ rubygems_version: 3.3.7
269
+ signing_key:
268
270
  specification_version: 4
269
271
  summary: Magic tools for a turnkey developer experience
270
272
  test_files: []