rbcli 0.1.10 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +31 -0
- data/CODE_OF_CONDUCT.md +1 -1
- data/Gemfile.lock +12 -12
- data/LICENSE.txt +674 -21
- data/README.md +80 -443
- data/bin/console +19 -0
- data/bin/setup +20 -0
- data/docs/404.html +639 -0
- data/docs/advanced/automatic_updates/index.html +791 -0
- data/docs/advanced/command_types/index.html +946 -0
- data/docs/advanced/distributed_state_locking/index.html +777 -0
- data/docs/advanced/hooks/index.html +836 -0
- data/docs/advanced/state_storage/index.html +957 -0
- data/docs/advanced/user_config_files/index.html +818 -0
- data/docs/assets/fonts/font-awesome.css +4 -0
- data/docs/assets/fonts/material-icons.css +13 -0
- data/docs/assets/fonts/specimen/FontAwesome.ttf +0 -0
- data/docs/assets/fonts/specimen/FontAwesome.woff +0 -0
- data/docs/assets/fonts/specimen/FontAwesome.woff2 +0 -0
- data/docs/assets/fonts/specimen/MaterialIcons-Regular.ttf +0 -0
- data/docs/assets/fonts/specimen/MaterialIcons-Regular.woff +0 -0
- data/docs/assets/fonts/specimen/MaterialIcons-Regular.woff2 +0 -0
- data/docs/assets/images/favicon.png +0 -0
- data/docs/assets/images/icons/bitbucket.1b09e088.svg +20 -0
- data/docs/assets/images/icons/github.f0b8504a.svg +18 -0
- data/docs/assets/images/icons/gitlab.6dd19c00.svg +38 -0
- data/docs/assets/javascripts/application.a59e2a89.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.da.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.de.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.du.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.es.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.fi.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.fr.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.hu.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.it.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.jp.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.multi.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.no.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.pt.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.ro.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.ru.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.stemmer.support.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.sv.js +1 -0
- data/docs/assets/javascripts/lunr/lunr.tr.js +1 -0
- data/docs/assets/javascripts/lunr/tinyseg.js +1 -0
- data/docs/assets/javascripts/modernizr.1aa3b519.js +1 -0
- data/docs/assets/stylesheets/application-palette.6079476c.css +2 -0
- data/docs/assets/stylesheets/application.ba0fd1a6.css +2 -0
- data/docs/development/code_of_conduct/index.html +883 -0
- data/docs/development/contributing/index.html +744 -0
- data/docs/development/license/index.html +715 -0
- data/docs/imported/changelog/index.html +853 -0
- data/docs/imported/quick_reference/index.html +1057 -0
- data/docs/index.html +732 -0
- data/docs/search/search_index.json +569 -0
- data/docs/sitemap.xml +93 -0
- data/docs/tutorial/10-getting_started/index.html +806 -0
- data/docs/tutorial/20-project_layout/index.html +972 -0
- data/docs/tutorial/30-your_first_command/index.html +906 -0
- data/docs/tutorial/40-options_parameters_and_arguments/index.html +1049 -0
- data/docs/tutorial/50-publishing/index.html +838 -0
- data/docs/whoami/index.html +709 -0
- data/docs-src/docs/advanced/automatic_updates.md +42 -0
- data/docs-src/docs/advanced/command_types.md +144 -0
- data/docs-src/docs/advanced/distributed_state_locking.md +33 -0
- data/docs-src/docs/advanced/hooks.md +65 -0
- data/docs-src/docs/advanced/logging.md +35 -0
- data/docs-src/docs/advanced/state_storage.md +117 -0
- data/docs-src/docs/advanced/user_config_files.md +47 -0
- data/docs-src/docs/development/code_of_conduct.md +74 -0
- data/docs-src/docs/development/contributing.md +49 -0
- data/docs-src/docs/development/license.md +10 -0
- data/docs-src/docs/imported/changelog.md +31 -0
- data/docs-src/docs/imported/quick_reference.md +150 -0
- data/docs-src/docs/index.md +38 -0
- data/docs-src/docs/tutorial/10-getting_started.md +41 -0
- data/docs-src/docs/tutorial/20-project_layout.md +115 -0
- data/docs-src/docs/tutorial/30-your_first_command.md +126 -0
- data/docs-src/docs/tutorial/40-options_parameters_and_arguments.md +251 -0
- data/docs-src/docs/tutorial/50-publishing.md +47 -0
- data/docs-src/docs/whoami.md +28 -0
- data/docs-src/makesite.sh +14 -0
- data/docs-src/mkdocs.yml +76 -0
- data/docs-src/runsite.sh +3 -0
- data/exe/rbcli +76 -5
- data/lib/rbcli/autoupdate/autoupdate.rb +24 -4
- data/lib/rbcli/autoupdate/gem_updater.rb +23 -2
- data/lib/rbcli/autoupdate/github_updater.rb +22 -1
- data/lib/rbcli/configuration/config.rb +22 -1
- data/lib/rbcli/configuration/configurate.rb +24 -2
- data/lib/rbcli/engine/command.rb +26 -6
- data/lib/rbcli/engine/load_project.rb +29 -3
- data/lib/rbcli/engine/parser.rb +25 -4
- data/lib/rbcli/logging/logging.rb +21 -0
- data/lib/rbcli/scriptwrapping/scriptwrapper.rb +30 -11
- data/lib/rbcli/stateful_systems/configuratestorage.rb +20 -0
- data/lib/rbcli/stateful_systems/state_storage.rb +20 -0
- data/lib/rbcli/stateful_systems/storagetypes/localstate.rb +20 -0
- data/lib/rbcli/stateful_systems/storagetypes/remote_state_connectors/dynamodb.rb +20 -0
- data/lib/rbcli/stateful_systems/storagetypes/remotestate_dynamodb.rb +20 -0
- data/lib/rbcli/util/hash_deep_symbolize.rb +43 -22
- data/lib/rbcli/util/string_colorize.rb +20 -0
- data/lib/rbcli/version.rb +21 -1
- data/lib/rbcli-tool/generators.rb +20 -0
- data/lib/rbcli-tool/mdless_fix.rb +20 -0
- data/lib/rbcli-tool/project.rb +27 -2
- data/lib/rbcli-tool/util.rb +20 -0
- data/lib/rbcli-tool.rb +20 -0
- data/lib/rbcli.rb +20 -0
- data/lib-sh/lib-rbcli.sh +19 -0
- data/rbcli.gemspec +22 -3
- data/skeletons/project/CODE_OF_CONDUCT.md +1 -1
- data/skeletons/project/README.md +17 -2
- data/skeletons/project/application/commands/command.erb +10 -8
- data/skeletons/project/application/commands/script.erb +3 -1
- data/skeletons/project/application/commands/scripts/script.sh +2 -2
- data/skeletons/project/application/options.rb +12 -3
- data/skeletons/project/config/autoupdate.rb +5 -2
- data/skeletons/project/config/storage.rb +7 -6
- data/skeletons/project/config/userspace.rb +6 -1
- data/skeletons/project/exe/executable +1 -1
- data/skeletons/project/lib/.keep +0 -0
- data/skeletons/project/untitled.gemspec +4 -4
- data/skeletons/project/{default_user_configs → userconf}/user_defaults.yml +0 -0
- metadata +85 -9
- data/examples/defaults.yml +0 -4
- data/examples/myscript.sh +0 -23
- data/examples/mytool +0 -95
data/examples/myscript.sh
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
|
3
|
-
###
|
4
|
-
# This is the RBCli script for the command {{**CMDNAME**}}
|
5
|
-
###
|
6
|
-
#
|
7
|
-
# You can find RBCli's params, args, global_opts, and config through environment
|
8
|
-
# variables. They are passed in the formats:
|
9
|
-
#
|
10
|
-
# __PARAMS_<param_name>
|
11
|
-
# __ARGS_<arg_name>
|
12
|
-
# __GOBAL <global_opt_name>
|
13
|
-
# __CONFIG <config_name>
|
14
|
-
#
|
15
|
-
# If any of the options given had nested values in your RBCli application they
|
16
|
-
# will be passed as JSON. You can parse them using jq ( https://stedolan.github.io/jq/ )
|
17
|
-
#
|
18
|
-
# If you specified any environment variables to be set manually, they will be found unmodified.
|
19
|
-
#
|
20
|
-
###
|
21
|
-
#
|
22
|
-
|
23
|
-
env | grep "^__PARAMS\|^__ARGS\|^__GLOBAL\|^__CONFIG"
|
data/examples/mytool
DELETED
@@ -1,95 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rbcli'
|
4
|
-
|
5
|
-
#########################
|
6
|
-
## Configuration Block ##
|
7
|
-
#########################
|
8
|
-
# This block is where rbcli is configured.
|
9
|
-
#########################
|
10
|
-
|
11
|
-
Rbcli::Configurate.me do
|
12
|
-
scriptname __FILE__.split('/')[-1] # (Required) This line identifies the tool's executable. You can change it if needed, but this should work for most cases.
|
13
|
-
version '0.1.0' # (Required) The version number
|
14
|
-
description 'This is my test CLI tool.' # (Requierd) A description that will appear when the user looks at the help with -h. This can be as long as needed.
|
15
|
-
|
16
|
-
log_level :info # (Optional) Set the default log_level for users. 0-5, or DEBUG < INFO < WARN < ERROR < FATAL < UNKNOWN
|
17
|
-
log_target 'stderr' # (Optional) Set the target for logs. Valid values are STDOUT, STDERR, or a file path (as strings)
|
18
|
-
|
19
|
-
config_userfile '/etc/mytool/config.yml', merge_defaults: true, required: false # (Optional) Set location of user's config file. If merge_defaults=true, user settings override default settings, and if false, defaults are not loaded at all. If required=true, application will not run if file does not exist.
|
20
|
-
config_defaults 'defaults.yml' # (Optional, Multiple) Load a YAML file as part of the default config. This can be called multiple times, and the YAML files will be merged. User config is generated from these
|
21
|
-
config_default :myopt, description: 'Testing this', value: true # (Optional, Multiple) Specify an individual configuration parameter and set a default value. These will also be included in generated user config
|
22
|
-
|
23
|
-
option :name, 'Give me your name', type: :string, default: 'Foo', required: false, permitted: ['Jack', 'Jill'] # (Optional, Multiple) Add a global CLI parameter. Supported types are :string, :boolean, :integer, :float, :date, and :io. Can be called multiple times.
|
24
|
-
|
25
|
-
autoupdate github_repo: 'akhoury6/rbcli', access_token: nil, enterprise_hostname: nil, force_update: false # (Optional) Check for updates to this application at a GitHub repo. The repo must use version number tags in accordance to best practices: https://help.github.com/articles/creating-releases/
|
26
|
-
autoupdate gem: 'rbcli', force_update: false # (Optional) Check for updates to this application through RubyGems.org.
|
27
|
-
|
28
|
-
default_action do |opts| # (Optional) The default code to execute when no subcommand is given. If not present, the help is shown (same as -h)
|
29
|
-
puts "Hello, #{opts[:name]}."
|
30
|
-
puts "To see the help, use -h"
|
31
|
-
end
|
32
|
-
|
33
|
-
pre_hook do |opts| # (Optional) Allows providing a block of code that runs before any command
|
34
|
-
puts 'This is a pre-command hook. It executes before the command.'
|
35
|
-
end
|
36
|
-
|
37
|
-
post_hook do |opts| # (Optional) Allows providing a block of code that runs after any command
|
38
|
-
puts 'This is a post-command hook. It executes after the command.'
|
39
|
-
end
|
40
|
-
|
41
|
-
first_run halt_after_running: false do # (Optional) Allows providing a block of code that executes the first time that the application is run on a given system. If `halt_after_running` is set to `true` then parsing will not continue after this code is executed. All subsequent runs will not execute this code.
|
42
|
-
puts "This is the first time the mytool command is run! Don't forget to generate a config file with the `-g` option before continuing."
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
###############################
|
47
|
-
## State Configuration Block ##
|
48
|
-
###############################
|
49
|
-
# The state-related componets
|
50
|
-
# are configured here.
|
51
|
-
###############################
|
52
|
-
Rbcli::Configurate.storage do
|
53
|
-
local_state '/var/mytool/localstate', force_creation: true, halt_on_error: true # (Optional) Creates a hash that is automatically saved to a file locally for state persistance. It is accessible to all commands at Rbcli.localstate[:yourkeyhere]
|
54
|
-
remote_state_dynamodb table_name: 'mytable', region: 'us-east-1', force_creation: true, halt_on_error: true, locking: :auto # (Optional) Creates a hash that is automatically saved to a DynamoDB table. It is recommended to keep halt_on_error=true when using a shared state. Locking can be one of (:manual :auto :none) -- see the README for details
|
55
|
-
end
|
56
|
-
|
57
|
-
#########################
|
58
|
-
## Command Declaration ##
|
59
|
-
#########################
|
60
|
-
# With rbcli, commands are declared by subclassing
|
61
|
-
# from Rbcli::Command. The name of the class will be
|
62
|
-
# the command that is available to the user.
|
63
|
-
#########################
|
64
|
-
class Test < Rbcli::Command # Declare a new command by subclassing Rbcli::Command
|
65
|
-
description 'This is a short description.' # (Required) Short description for the global help
|
66
|
-
usage 'This is some really long usage text description!' # (Required) Long description for the command-specific help
|
67
|
-
parameter :force, 'Force testing', type: :boolean, default: false, required: false # (Optional, Multiple) Add a command-specific CLI parameter. Can be called multiple times
|
68
|
-
|
69
|
-
config_defaults 'defaults.yml' # (Optional, Multiple) Load a YAML file as part of the default config. This can be called multiple times, and the YAML files will be merged. User config is generated from these
|
70
|
-
config_default :myopt2, description: 'Testing this again', value: true # (Optional, Multiple) Specify an individual configuration parameter and set a default value. These will also be included in generated user config
|
71
|
-
|
72
|
-
extern path: 'env | grep "^__PARAMS\|^__ARGS\|^__GLOBAL\|^__CONFIG"', envvars: {MYVAR: 'some_value'} # (Required unless `action` defined) Runs a given application, with optional environment variables, when the user runs the command.
|
73
|
-
extern envvars: {MY_OTHER_VAR: 'another_value'} do |params, args, global_opts, config| # Alternate usage. Supplying a block instead of a path allows us to modify the command based on the arguments and configuration supplied by the user.
|
74
|
-
"echo #{params[:force].to_s}__YESSS!!!"
|
75
|
-
end
|
76
|
-
|
77
|
-
action do |params, args, global_opts, config| # (Required unless `extern` defined) Block to execute if the command is called.
|
78
|
-
Rbcli::log.info { 'These logs can go to STDERR, STDOUT, or a file' } # Example log. Interface is identical to Ruby's logger
|
79
|
-
puts "\nArgs:\n#{args}" # Arguments that came after the command on the CLI (i.e.: `mytool test bar baz` will yield args=['bar', 'baz'])
|
80
|
-
puts "Params:\n#{params}" # Parameters, as described through the option statements above
|
81
|
-
puts "Global opts:\n#{global_opts}" # Global Parameters, as descirbed in the Configurate section
|
82
|
-
puts "Config:\n#{config}" # Config file values
|
83
|
-
puts "LocalState:\n#{Rbcli.local_state}" # Local persistent state storage (when available) -- if unsure use Rbcli.local_state.nil?
|
84
|
-
puts "RemoteState:\n#{Rbcli.remote_state}" # Remote persistent state storage (when available) -- if unsure use Rbcli.remote_state.nil?
|
85
|
-
puts "\nDone!!!"
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
#####################
|
90
|
-
## Parse Statement ##
|
91
|
-
#####################
|
92
|
-
# When this statement is called, the CLI will be
|
93
|
-
# parsed and code executed.
|
94
|
-
#####################
|
95
|
-
Rbcli.parse # Parse CLI and execute
|