Skip to content

Commit 199cd17

Browse files
committed
fix(cli): Add a known bug to cli load help
1 parent 21c2511 commit 199cd17

File tree

1 file changed

+71
-4
lines changed

1 file changed

+71
-4
lines changed

openc3/bin/openc3cli

Lines changed: 71 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -875,13 +875,52 @@ if not ARGV[0].nil? # argument(s) given
875875
case ARGV[0].downcase
876876

877877
when 'irb'
878+
if ARGV[1] == '--help' || ARGV[1] == '-h'
879+
puts "Usage: cli irb"
880+
puts ""
881+
puts "Start an interactive Ruby (IRB) session with COSMOS libraries loaded"
882+
puts ""
883+
puts "This provides access to all COSMOS classes and methods for interactive"
884+
puts "debugging and exploration. Use 'exit' or Ctrl-D to quit the IRB session."
885+
puts ""
886+
puts "Example:"
887+
puts " cli irb"
888+
puts " > require 'openc3'"
889+
puts " > OpenC3::System.targets"
890+
puts ""
891+
puts "Note: For IRB-specific options, start IRB first then type 'help'"
892+
exit 0
893+
end
878894
ARGV.clear
879895
IRB.start
880896

881897
when 'script'
882898
cli_script(ARGV[1..-1])
883899

884900
when 'rake'
901+
# Check for --help first, before checking for Rakefile
902+
if ARGV[1] == '--help' || ARGV[1] == '-h'
903+
puts "Usage: cli rake [RAKE_OPTIONS] [TASKS...]"
904+
puts ""
905+
puts "Run rake tasks in the current directory"
906+
puts ""
907+
puts "This runs the standard Ruby rake tool with all COSMOS libraries available."
908+
puts "A Rakefile must exist in the current directory."
909+
puts ""
910+
puts "Common rake options:"
911+
puts " -T, --tasks List all available rake tasks with descriptions"
912+
puts " -D, --describe PATTERN Describe tasks matching PATTERN"
913+
puts " -h, --help Show rake's full help message"
914+
puts ""
915+
puts "Examples:"
916+
puts " cli rake -T # List all available tasks"
917+
puts " cli rake build # Run the 'build' task"
918+
puts " cli rake test # Run tests"
919+
puts ""
920+
puts "Note: Must be run in a directory containing a Rakefile"
921+
exit 0
922+
end
923+
# Now check for Rakefile existence
885924
if File.exist?('Rakefile')
886925
puts `rake #{ARGV[1..-1].join(' ')}`
887926
else
@@ -908,20 +947,48 @@ if not ARGV[0].nil? # argument(s) given
908947
when 'load'
909948
# Check for help flag or missing arguments
910949
if ARGV[1].nil? || ARGV[1] == '--help' || ARGV[1] == '-h'
911-
puts "Usage: cli load PLUGIN.gem [SCOPE] [PLUGIN_HASH.json] [force]"
912-
puts " or: cli load PLUGIN.gem --variables VARIABLES.json [SCOPE] [PLUGIN_HASH.json] [force]"
950+
puts "Usage:"
951+
puts " cli load PLUGIN.gem"
952+
puts " cli load PLUGIN.gem --variables VARIABLES.json"
953+
puts " cli load PLUGIN.gem SCOPE PLUGIN_HASH.json [force]"
954+
puts " cli load PLUGIN.gem --variables VARIABLES.json SCOPE PLUGIN_HASH.json [force]"
913955
puts ""
914956
puts "Load a COSMOS plugin gem file"
915957
puts ""
958+
puts "Common Usage (Auto-detect):"
959+
puts " cli load PLUGIN.gem"
960+
puts " - Installs new plugin in DEFAULT scope"
961+
puts " - Automatically detects and upgrades if plugin already exists"
962+
puts " - Skips installation if same version already installed"
963+
puts ""
964+
puts " cli load PLUGIN.gem --variables VARIABLES.json"
965+
puts " - Same as above, but provides variables for plugin configuration"
966+
puts ""
967+
puts "Advanced Usage (Manual Control):"
968+
puts " cli load PLUGIN.gem SCOPE PLUGIN_HASH.json [force]"
969+
puts " - Used by Admin UI for plugin create/edit/upgrade operations"
970+
puts " - Requires PLUGIN_HASH.json (output from install_phase1)"
971+
puts " - 'force' argument forces reinstall even if version unchanged"
972+
puts ""
916973
puts "Arguments:"
917974
puts " PLUGIN.gem Plugin gem file to load (required)"
918975
puts " SCOPE Scope to install plugin in (default: DEFAULT)"
919-
puts " PLUGIN_HASH.json Plugin hash JSON file (optional)"
920-
puts " force Force plugin installation (optional)"
976+
puts " PLUGIN_HASH.json Plugin hash JSON file from install_phase1 (optional)"
977+
puts " force Force plugin installation even if no changes (optional)"
921978
puts ""
922979
puts "Options:"
923980
puts " --variables FILE Variables JSON file for plugin installation"
924981
puts " -h, --help Show this help message"
982+
puts ""
983+
puts "IMPORTANT LIMITATION:"
984+
puts " To specify SCOPE without PLUGIN_HASH.json, you must use the --variables"
985+
puts " option (even with an empty JSON file) to prevent argument misinterpretation."
986+
puts ""
987+
puts "Examples:"
988+
puts " cli load my-plugin-1.0.0.gem"
989+
puts " cli load my-plugin-1.0.0.gem --variables vars.json"
990+
puts " cli load my-plugin-1.0.0.gem DEFAULT plugin_hash.json"
991+
puts " cli load my-plugin-1.0.0.gem DEFAULT plugin_hash.json force"
925992
exit(ARGV[1].nil? ? 1 : 0)
926993
end
927994

0 commit comments

Comments
 (0)