fluid_cli 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +1 -0
- data/dev.yml +5 -0
- data/exe/fluid +24 -0
- data/lib/fluid_cli/api.rb +135 -0
- data/lib/fluid_cli/assets/post_auth_page/index.html.erb +34 -0
- data/lib/fluid_cli/assets/post_auth_page/style.css +58 -0
- data/lib/fluid_cli/command.rb +55 -0
- data/lib/fluid_cli/commands/help.rb +21 -0
- data/lib/fluid_cli/commands/login.rb +30 -0
- data/lib/fluid_cli/commands/logout.rb +38 -0
- data/lib/fluid_cli/commands/switch.rb +23 -0
- data/lib/fluid_cli/commands/theme/common/company_helper.rb +15 -0
- data/lib/fluid_cli/commands/theme/common/root_helper.rb +95 -0
- data/lib/fluid_cli/commands/theme/dev.rb +61 -0
- data/lib/fluid_cli/commands/theme/help.rb +21 -0
- data/lib/fluid_cli/commands/theme/init.rb +46 -0
- data/lib/fluid_cli/commands/theme/pull.rb +68 -0
- data/lib/fluid_cli/commands/theme/push.rb +132 -0
- data/lib/fluid_cli/commands/theme.rb +23 -0
- data/lib/fluid_cli/commands/whoami.rb +23 -0
- data/lib/fluid_cli/commands.rb +19 -0
- data/lib/fluid_cli/company_switcher.rb +69 -0
- data/lib/fluid_cli/context.rb +691 -0
- data/lib/fluid_cli/db.rb +114 -0
- data/lib/fluid_cli/entry_point.rb +10 -0
- data/lib/fluid_cli/environment.rb +32 -0
- data/lib/fluid_cli/file_system_listener.rb +29 -0
- data/lib/fluid_cli/form.rb +42 -0
- data/lib/fluid_cli/git.rb +319 -0
- data/lib/fluid_cli/http_request.rb +54 -0
- data/lib/fluid_cli/identity_auth/servlet.rb +39 -0
- data/lib/fluid_cli/identity_auth.rb +126 -0
- data/lib/fluid_cli/options.rb +38 -0
- data/lib/fluid_cli/theme/dev_server/certificate_manager.rb +79 -0
- data/lib/fluid_cli/theme/dev_server/errors.rb +9 -0
- data/lib/fluid_cli/theme/dev_server/header_hash.rb +98 -0
- data/lib/fluid_cli/theme/dev_server/hooks/file_change_hook.rb +39 -0
- data/lib/fluid_cli/theme/dev_server/hot_reload/resources/hot-reload-no-script.html +27 -0
- data/lib/fluid_cli/theme/dev_server/hot_reload/resources/hot_reload.js +28 -0
- data/lib/fluid_cli/theme/dev_server/hot_reload/resources/sse_client.js +43 -0
- data/lib/fluid_cli/theme/dev_server/hot_reload/resources/theme.js +16 -0
- data/lib/fluid_cli/theme/dev_server/hot_reload/script_injector.rb +54 -0
- data/lib/fluid_cli/theme/dev_server/hot_reload.rb +75 -0
- data/lib/fluid_cli/theme/dev_server/local_assets.rb +92 -0
- data/lib/fluid_cli/theme/dev_server/proxy.rb +235 -0
- data/lib/fluid_cli/theme/dev_server/proxy_param_builder.rb +82 -0
- data/lib/fluid_cli/theme/dev_server/reload_mode.rb +34 -0
- data/lib/fluid_cli/theme/dev_server/sse.rb +75 -0
- data/lib/fluid_cli/theme/dev_server/watcher.rb +57 -0
- data/lib/fluid_cli/theme/dev_server/web_server.rb +140 -0
- data/lib/fluid_cli/theme/dev_server.rb +289 -0
- data/lib/fluid_cli/theme/development_theme.rb +101 -0
- data/lib/fluid_cli/theme/file.rb +105 -0
- data/lib/fluid_cli/theme/forms/select.rb +33 -0
- data/lib/fluid_cli/theme/mime_type.rb +34 -0
- data/lib/fluid_cli/theme/presenters/theme_presenter.rb +49 -0
- data/lib/fluid_cli/theme/presenters/themes_presenter.rb +31 -0
- data/lib/fluid_cli/theme/root.rb +62 -0
- data/lib/fluid_cli/theme/syncer/checksums.rb +66 -0
- data/lib/fluid_cli/theme/syncer/downloader.rb +54 -0
- data/lib/fluid_cli/theme/syncer/error_reporter.rb +45 -0
- data/lib/fluid_cli/theme/syncer/merger.rb +53 -0
- data/lib/fluid_cli/theme/syncer/operation.rb +58 -0
- data/lib/fluid_cli/theme/syncer/standard_reporter.rb +32 -0
- data/lib/fluid_cli/theme/syncer/unsupported_script_warning.rb +90 -0
- data/lib/fluid_cli/theme/syncer/uploader/forms/apply_to_all.rb +41 -0
- data/lib/fluid_cli/theme/syncer/uploader/forms/apply_to_all_form.rb +37 -0
- data/lib/fluid_cli/theme/syncer/uploader/forms/base_strategy_form.rb +64 -0
- data/lib/fluid_cli/theme/syncer/uploader/forms/select_delete_strategy.rb +29 -0
- data/lib/fluid_cli/theme/syncer/uploader/forms/select_update_strategy.rb +30 -0
- data/lib/fluid_cli/theme/syncer/uploader/json_delete_handler.rb +49 -0
- data/lib/fluid_cli/theme/syncer/uploader/json_update_handler.rb +71 -0
- data/lib/fluid_cli/theme/syncer/uploader.rb +105 -0
- data/lib/fluid_cli/theme/syncer.rb +412 -0
- data/lib/fluid_cli/theme/theme.rb +186 -0
- data/lib/fluid_cli/theme/ui/sync_progress_bar.rb +22 -0
- data/lib/fluid_cli/thread_pool/job.rb +35 -0
- data/lib/fluid_cli/thread_pool.rb +49 -0
- data/lib/fluid_cli/version.rb +3 -0
- data/lib/fluid_cli.rb +59 -0
- data/vendor/deps/base64/.document +5 -0
- data/vendor/deps/base64/.gitignore +9 -0
- data/vendor/deps/base64/BSDL +22 -0
- data/vendor/deps/base64/COPYING +56 -0
- data/vendor/deps/base64/Gemfile +9 -0
- data/vendor/deps/base64/LEGAL +60 -0
- data/vendor/deps/base64/README.md +48 -0
- data/vendor/deps/base64/Rakefile +31 -0
- data/vendor/deps/base64/base64.gemspec +28 -0
- data/vendor/deps/base64/bin/console +14 -0
- data/vendor/deps/base64/bin/setup +8 -0
- data/vendor/deps/base64/lib/base64.rb +382 -0
- data/vendor/deps/base64/sig/base64.rbs +358 -0
- data/vendor/deps/base64/test/base64/test_base64.rb +115 -0
- data/vendor/deps/base64/test_sig/test_base64.rb +44 -0
- data/vendor/deps/cli-kit/REVISION +1 -0
- data/vendor/deps/cli-kit/lib/cli/kit/args/definition.rb +286 -0
- data/vendor/deps/cli-kit/lib/cli/kit/args/evaluation.rb +215 -0
- data/vendor/deps/cli-kit/lib/cli/kit/args/parser/node.rb +128 -0
- data/vendor/deps/cli-kit/lib/cli/kit/args/parser.rb +125 -0
- data/vendor/deps/cli-kit/lib/cli/kit/args/tokenizer.rb +130 -0
- data/vendor/deps/cli-kit/lib/cli/kit/args.rb +16 -0
- data/vendor/deps/cli-kit/lib/cli/kit/base_command.rb +30 -0
- data/vendor/deps/cli-kit/lib/cli/kit/command_help.rb +268 -0
- data/vendor/deps/cli-kit/lib/cli/kit/command_registry.rb +150 -0
- data/vendor/deps/cli-kit/lib/cli/kit/config.rb +137 -0
- data/vendor/deps/cli-kit/lib/cli/kit/core_ext.rb +28 -0
- data/vendor/deps/cli-kit/lib/cli/kit/error_handler.rb +166 -0
- data/vendor/deps/cli-kit/lib/cli/kit/executor.rb +92 -0
- data/vendor/deps/cli-kit/lib/cli/kit/ini.rb +91 -0
- data/vendor/deps/cli-kit/lib/cli/kit/levenshtein.rb +92 -0
- data/vendor/deps/cli-kit/lib/cli/kit/logger.rb +94 -0
- data/vendor/deps/cli-kit/lib/cli/kit/opts.rb +248 -0
- data/vendor/deps/cli-kit/lib/cli/kit/parse_args.rb +55 -0
- data/vendor/deps/cli-kit/lib/cli/kit/resolver.rb +66 -0
- data/vendor/deps/cli-kit/lib/cli/kit/support/test_helper.rb +260 -0
- data/vendor/deps/cli-kit/lib/cli/kit/support.rb +11 -0
- data/vendor/deps/cli-kit/lib/cli/kit/system.rb +290 -0
- data/vendor/deps/cli-kit/lib/cli/kit/util.rb +118 -0
- data/vendor/deps/cli-kit/lib/cli/kit/version.rb +7 -0
- data/vendor/deps/cli-kit/lib/cli/kit.rb +139 -0
- data/vendor/deps/cli-ui/REVISION +1 -0
- data/vendor/deps/cli-ui/lib/cli/ui/ansi.rb +218 -0
- data/vendor/deps/cli-ui/lib/cli/ui/color.rb +101 -0
- data/vendor/deps/cli-ui/lib/cli/ui/formatter.rb +219 -0
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_stack.rb +67 -0
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/box.rb +179 -0
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/bracket.rb +152 -0
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style.rb +127 -0
- data/vendor/deps/cli-ui/lib/cli/ui/frame.rb +286 -0
- data/vendor/deps/cli-ui/lib/cli/ui/glyph.rb +92 -0
- data/vendor/deps/cli-ui/lib/cli/ui/os.rb +63 -0
- data/vendor/deps/cli-ui/lib/cli/ui/printer.rb +64 -0
- data/vendor/deps/cli-ui/lib/cli/ui/progress.rb +132 -0
- data/vendor/deps/cli-ui/lib/cli/ui/progress_reporter.rb +209 -0
- data/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +583 -0
- data/vendor/deps/cli-ui/lib/cli/ui/prompt/options_handler.rb +36 -0
- data/vendor/deps/cli-ui/lib/cli/ui/prompt.rb +381 -0
- data/vendor/deps/cli-ui/lib/cli/ui/spinner/async.rb +48 -0
- data/vendor/deps/cli-ui/lib/cli/ui/spinner/spin_group.rb +602 -0
- data/vendor/deps/cli-ui/lib/cli/ui/spinner.rb +79 -0
- data/vendor/deps/cli-ui/lib/cli/ui/stdout_router.rb +399 -0
- data/vendor/deps/cli-ui/lib/cli/ui/table.rb +83 -0
- data/vendor/deps/cli-ui/lib/cli/ui/terminal.rb +55 -0
- data/vendor/deps/cli-ui/lib/cli/ui/truncater.rb +106 -0
- data/vendor/deps/cli-ui/lib/cli/ui/version.rb +8 -0
- data/vendor/deps/cli-ui/lib/cli/ui/widgets/base.rb +46 -0
- data/vendor/deps/cli-ui/lib/cli/ui/widgets/status.rb +79 -0
- data/vendor/deps/cli-ui/lib/cli/ui/widgets.rb +89 -0
- data/vendor/deps/cli-ui/lib/cli/ui/work_queue.rb +142 -0
- data/vendor/deps/cli-ui/lib/cli/ui/wrap.rb +61 -0
- data/vendor/deps/cli-ui/lib/cli/ui.rb +359 -0
- data/vendor/deps/cli-ui/vendor/reentrant_mutex.rb +78 -0
- data/vendor/deps/debug/CONTRIBUTING.md +573 -0
- data/vendor/deps/debug/Gemfile +10 -0
- data/vendor/deps/debug/LICENSE.txt +22 -0
- data/vendor/deps/debug/README.md +996 -0
- data/vendor/deps/debug/Rakefile +57 -0
- data/vendor/deps/debug/TODO.md +23 -0
- data/vendor/deps/debug/debug.gemspec +33 -0
- data/vendor/deps/debug/exe/rdbg +53 -0
- data/vendor/deps/debug/ext/debug/Makefile +273 -0
- data/vendor/deps/debug/ext/debug/debug.c +228 -0
- data/vendor/deps/debug/ext/debug/debug_version.h +1 -0
- data/vendor/deps/debug/ext/debug/extconf.rb +27 -0
- data/vendor/deps/debug/ext/debug/iseq_collector.c +93 -0
- data/vendor/deps/debug/lib/debug/abbrev_command.rb +77 -0
- data/vendor/deps/debug/lib/debug/breakpoint.rb +556 -0
- data/vendor/deps/debug/lib/debug/client.rb +263 -0
- data/vendor/deps/debug/lib/debug/color.rb +123 -0
- data/vendor/deps/debug/lib/debug/config.rb +592 -0
- data/vendor/deps/debug/lib/debug/console.rb +224 -0
- data/vendor/deps/debug/lib/debug/dap_custom/traceInspector.rb +336 -0
- data/vendor/deps/debug/lib/debug/debug.bundle +0 -0
- data/vendor/deps/debug/lib/debug/frame_info.rb +190 -0
- data/vendor/deps/debug/lib/debug/irb_integration.rb +37 -0
- data/vendor/deps/debug/lib/debug/local.rb +115 -0
- data/vendor/deps/debug/lib/debug/open.rb +13 -0
- data/vendor/deps/debug/lib/debug/open_nonstop.rb +15 -0
- data/vendor/deps/debug/lib/debug/prelude.rb +50 -0
- data/vendor/deps/debug/lib/debug/server.rb +534 -0
- data/vendor/deps/debug/lib/debug/server_cdp.rb +1348 -0
- data/vendor/deps/debug/lib/debug/server_dap.rb +1108 -0
- data/vendor/deps/debug/lib/debug/session.rb +2667 -0
- data/vendor/deps/debug/lib/debug/source_repository.rb +150 -0
- data/vendor/deps/debug/lib/debug/start.rb +5 -0
- data/vendor/deps/debug/lib/debug/thread_client.rb +1457 -0
- data/vendor/deps/debug/lib/debug/tracer.rb +241 -0
- data/vendor/deps/debug/lib/debug/version.rb +5 -0
- data/vendor/deps/debug/lib/debug.rb +9 -0
- data/vendor/deps/debug/misc/README.md.erb +660 -0
- data/vendor/deps/listen/.github/release-drafter.yml +17 -0
- data/vendor/deps/listen/.github/workflows/development.yml +67 -0
- data/vendor/deps/listen/.github/workflows/push.yml +12 -0
- data/vendor/deps/listen/.gitignore +28 -0
- data/vendor/deps/listen/.rspec +3 -0
- data/vendor/deps/listen/.rubocop.yml +283 -0
- data/vendor/deps/listen/.yardopts +11 -0
- data/vendor/deps/listen/CHANGELOG.md +1 -0
- data/vendor/deps/listen/CONTRIBUTING.md +45 -0
- data/vendor/deps/listen/Gemfile +33 -0
- data/vendor/deps/listen/Guardfile +26 -0
- data/vendor/deps/listen/LICENSE.txt +22 -0
- data/vendor/deps/listen/README.md +490 -0
- data/vendor/deps/listen/Rakefile +154 -0
- data/vendor/deps/listen/bin/listen +11 -0
- data/vendor/deps/listen/lib/listen/adapter/base.rb +129 -0
- data/vendor/deps/listen/lib/listen/adapter/bsd.rb +104 -0
- data/vendor/deps/listen/lib/listen/adapter/config.rb +31 -0
- data/vendor/deps/listen/lib/listen/adapter/darwin.rb +77 -0
- data/vendor/deps/listen/lib/listen/adapter/linux.rb +108 -0
- data/vendor/deps/listen/lib/listen/adapter/polling.rb +40 -0
- data/vendor/deps/listen/lib/listen/adapter/windows.rb +96 -0
- data/vendor/deps/listen/lib/listen/adapter.rb +43 -0
- data/vendor/deps/listen/lib/listen/backend.rb +40 -0
- data/vendor/deps/listen/lib/listen/change.rb +69 -0
- data/vendor/deps/listen/lib/listen/cli.rb +65 -0
- data/vendor/deps/listen/lib/listen/directory.rb +93 -0
- data/vendor/deps/listen/lib/listen/error.rb +11 -0
- data/vendor/deps/listen/lib/listen/event/config.rb +39 -0
- data/vendor/deps/listen/lib/listen/event/loop.rb +92 -0
- data/vendor/deps/listen/lib/listen/event/processor.rb +128 -0
- data/vendor/deps/listen/lib/listen/event/queue.rb +52 -0
- data/vendor/deps/listen/lib/listen/file.rb +95 -0
- data/vendor/deps/listen/lib/listen/fsm.rb +131 -0
- data/vendor/deps/listen/lib/listen/listener/config.rb +41 -0
- data/vendor/deps/listen/lib/listen/listener.rb +136 -0
- data/vendor/deps/listen/lib/listen/logger.rb +65 -0
- data/vendor/deps/listen/lib/listen/monotonic_time.rb +27 -0
- data/vendor/deps/listen/lib/listen/options.rb +24 -0
- data/vendor/deps/listen/lib/listen/queue_optimizer.rb +129 -0
- data/vendor/deps/listen/lib/listen/record/entry.rb +66 -0
- data/vendor/deps/listen/lib/listen/record/symlink_detector.rb +47 -0
- data/vendor/deps/listen/lib/listen/record.rb +122 -0
- data/vendor/deps/listen/lib/listen/silencer/controller.rb +50 -0
- data/vendor/deps/listen/lib/listen/silencer.rb +106 -0
- data/vendor/deps/listen/lib/listen/thread.rb +54 -0
- data/vendor/deps/listen/lib/listen/version.rb +5 -0
- data/vendor/deps/listen/lib/listen.rb +47 -0
- data/vendor/deps/listen/listen.gemspec +40 -0
- data/vendor/deps/listen/spec/acceptance/listen_spec.rb +320 -0
- data/vendor/deps/listen/spec/lib/listen/adapter/base_spec.rb +101 -0
- data/vendor/deps/listen/spec/lib/listen/adapter/bsd_spec.rb +13 -0
- data/vendor/deps/listen/spec/lib/listen/adapter/config_spec.rb +122 -0
- data/vendor/deps/listen/spec/lib/listen/adapter/darwin_spec.rb +82 -0
- data/vendor/deps/listen/spec/lib/listen/adapter/linux_spec.rb +199 -0
- data/vendor/deps/listen/spec/lib/listen/adapter/polling_spec.rb +83 -0
- data/vendor/deps/listen/spec/lib/listen/adapter/windows_spec.rb +13 -0
- data/vendor/deps/listen/spec/lib/listen/adapter_spec.rb +69 -0
- data/vendor/deps/listen/spec/lib/listen/backend_spec.rb +82 -0
- data/vendor/deps/listen/spec/lib/listen/change_spec.rb +102 -0
- data/vendor/deps/listen/spec/lib/listen/cli_spec.rb +116 -0
- data/vendor/deps/listen/spec/lib/listen/directory_spec.rb +284 -0
- data/vendor/deps/listen/spec/lib/listen/event/config_spec.rb +33 -0
- data/vendor/deps/listen/spec/lib/listen/event/loop_spec.rb +118 -0
- data/vendor/deps/listen/spec/lib/listen/event/processor_spec.rb +250 -0
- data/vendor/deps/listen/spec/lib/listen/event/queue_spec.rb +118 -0
- data/vendor/deps/listen/spec/lib/listen/file_spec.rb +254 -0
- data/vendor/deps/listen/spec/lib/listen/fsm_spec.rb +147 -0
- data/vendor/deps/listen/spec/lib/listen/listener/config_spec.rb +29 -0
- data/vendor/deps/listen/spec/lib/listen/listener_spec.rb +321 -0
- data/vendor/deps/listen/spec/lib/listen/logger_spec.rb +212 -0
- data/vendor/deps/listen/spec/lib/listen/monotonic_time_spec.rb +58 -0
- data/vendor/deps/listen/spec/lib/listen/queue_optimizer_spec.rb +111 -0
- data/vendor/deps/listen/spec/lib/listen/record_spec.rb +424 -0
- data/vendor/deps/listen/spec/lib/listen/silencer/controller_spec.rb +97 -0
- data/vendor/deps/listen/spec/lib/listen/silencer_spec.rb +109 -0
- data/vendor/deps/listen/spec/lib/listen/thread_spec.rb +133 -0
- data/vendor/deps/listen/spec/lib/listen_spec.rb +25 -0
- data/vendor/deps/listen/spec/spec_helper.rb +49 -0
- data/vendor/deps/listen/spec/support/acceptance_helper.rb +260 -0
- data/vendor/deps/listen/spec/support/fixtures_helper.rb +32 -0
- data/vendor/deps/listen/spec/support/platform_helper.rb +17 -0
- data/vendor/deps/observer/.github/dependabot.yml +6 -0
- data/vendor/deps/observer/.github/workflows/test.yml +33 -0
- data/vendor/deps/observer/.gitignore +8 -0
- data/vendor/deps/observer/BSDL +22 -0
- data/vendor/deps/observer/COPYING +56 -0
- data/vendor/deps/observer/Gemfile +9 -0
- data/vendor/deps/observer/README.md +139 -0
- data/vendor/deps/observer/Rakefile +10 -0
- data/vendor/deps/observer/bin/console +14 -0
- data/vendor/deps/observer/bin/setup +8 -0
- data/vendor/deps/observer/lib/observer.rb +229 -0
- data/vendor/deps/observer/observer.gemspec +32 -0
- data/vendor/deps/observer/test/test_observer.rb +66 -0
- data/vendor/deps/webrick/.gitignore +9 -0
- data/vendor/deps/webrick/Gemfile +3 -0
- data/vendor/deps/webrick/LICENSE.txt +22 -0
- data/vendor/deps/webrick/README.md +61 -0
- data/vendor/deps/webrick/Rakefile +10 -0
- data/vendor/deps/webrick/lib/webrick/accesslog.rb +157 -0
- data/vendor/deps/webrick/lib/webrick/cgi.rb +313 -0
- data/vendor/deps/webrick/lib/webrick/compat.rb +36 -0
- data/vendor/deps/webrick/lib/webrick/config.rb +158 -0
- data/vendor/deps/webrick/lib/webrick/cookie.rb +172 -0
- data/vendor/deps/webrick/lib/webrick/htmlutils.rb +30 -0
- data/vendor/deps/webrick/lib/webrick/httpauth/authenticator.rb +117 -0
- data/vendor/deps/webrick/lib/webrick/httpauth/basicauth.rb +116 -0
- data/vendor/deps/webrick/lib/webrick/httpauth/digestauth.rb +395 -0
- data/vendor/deps/webrick/lib/webrick/httpauth/htdigest.rb +132 -0
- data/vendor/deps/webrick/lib/webrick/httpauth/htgroup.rb +97 -0
- data/vendor/deps/webrick/lib/webrick/httpauth/htpasswd.rb +158 -0
- data/vendor/deps/webrick/lib/webrick/httpauth/userdb.rb +53 -0
- data/vendor/deps/webrick/lib/webrick/httpauth.rb +96 -0
- data/vendor/deps/webrick/lib/webrick/httpproxy.rb +354 -0
- data/vendor/deps/webrick/lib/webrick/httprequest.rb +636 -0
- data/vendor/deps/webrick/lib/webrick/httpresponse.rb +564 -0
- data/vendor/deps/webrick/lib/webrick/https.rb +152 -0
- data/vendor/deps/webrick/lib/webrick/httpserver.rb +294 -0
- data/vendor/deps/webrick/lib/webrick/httpservlet/abstract.rb +152 -0
- data/vendor/deps/webrick/lib/webrick/httpservlet/cgi_runner.rb +47 -0
- data/vendor/deps/webrick/lib/webrick/httpservlet/cgihandler.rb +126 -0
- data/vendor/deps/webrick/lib/webrick/httpservlet/erbhandler.rb +88 -0
- data/vendor/deps/webrick/lib/webrick/httpservlet/filehandler.rb +552 -0
- data/vendor/deps/webrick/lib/webrick/httpservlet/prochandler.rb +47 -0
- data/vendor/deps/webrick/lib/webrick/httpservlet.rb +23 -0
- data/vendor/deps/webrick/lib/webrick/httpstatus.rb +194 -0
- data/vendor/deps/webrick/lib/webrick/httputils.rb +512 -0
- data/vendor/deps/webrick/lib/webrick/httpversion.rb +76 -0
- data/vendor/deps/webrick/lib/webrick/log.rb +156 -0
- data/vendor/deps/webrick/lib/webrick/server.rb +381 -0
- data/vendor/deps/webrick/lib/webrick/ssl.rb +215 -0
- data/vendor/deps/webrick/lib/webrick/utils.rb +265 -0
- data/vendor/deps/webrick/lib/webrick/version.rb +18 -0
- data/vendor/deps/webrick/lib/webrick.rb +232 -0
- data/vendor/deps/webrick/webrick.gemspec +74 -0
- metadata +412 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
|
|
3
|
+
require 'cli/kit'
|
|
4
|
+
|
|
5
|
+
module CLI
|
|
6
|
+
module Kit
|
|
7
|
+
class CommandRegistry
|
|
8
|
+
#: type command_or_proc = singleton(CLI::Kit::BaseCommand) | ^() -> singleton(CLI::Kit::BaseCommand)
|
|
9
|
+
|
|
10
|
+
#: Hash[String, command_or_proc]
|
|
11
|
+
attr_reader :commands
|
|
12
|
+
|
|
13
|
+
#: Hash[String, String]
|
|
14
|
+
attr_reader :aliases
|
|
15
|
+
|
|
16
|
+
# @interface
|
|
17
|
+
module ContextualResolver
|
|
18
|
+
# @abstract
|
|
19
|
+
#: -> Array[String]
|
|
20
|
+
def command_names
|
|
21
|
+
raise(NotImplementedError)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# @abstract
|
|
25
|
+
#: -> Hash[String, String]
|
|
26
|
+
def aliases
|
|
27
|
+
raise(NotImplementedError)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# @abstract
|
|
31
|
+
#: (String) -> singleton(CLI::Kit::BaseCommand)
|
|
32
|
+
def command_class(_name)
|
|
33
|
+
raise(NotImplementedError)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
module NullContextualResolver
|
|
38
|
+
extend ContextualResolver
|
|
39
|
+
|
|
40
|
+
class << self
|
|
41
|
+
# @override
|
|
42
|
+
#: -> Array[String]
|
|
43
|
+
def command_names
|
|
44
|
+
[]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# @override
|
|
48
|
+
#: -> Hash[String, String]
|
|
49
|
+
def aliases
|
|
50
|
+
{}
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# @override
|
|
54
|
+
#: (String _name) -> singleton(CLI::Kit::BaseCommand)
|
|
55
|
+
def command_class(_name)
|
|
56
|
+
raise(CLI::Kit::Abort, 'Cannot be called on the NullContextualResolver since command_names is empty')
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
#: (default: String, ?contextual_resolver: ContextualResolver) -> void
|
|
62
|
+
def initialize(default:, contextual_resolver: NullContextualResolver)
|
|
63
|
+
@commands = {}
|
|
64
|
+
@aliases = {}
|
|
65
|
+
@default = default
|
|
66
|
+
@contextual_resolver = contextual_resolver
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
#: -> Hash[String, singleton(CLI::Kit::BaseCommand)]
|
|
70
|
+
def resolved_commands
|
|
71
|
+
@commands.each_with_object({}) do |(k, v), a|
|
|
72
|
+
a[k] = resolve_class(v)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
#: (command_or_proc const, String name) -> void
|
|
77
|
+
def add(const, name)
|
|
78
|
+
commands[name] = const
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
#: (String? name) -> [singleton(CLI::Kit::BaseCommand)?, String]
|
|
82
|
+
def lookup_command(name)
|
|
83
|
+
name = @default if name.to_s.empty?
|
|
84
|
+
resolve_command(
|
|
85
|
+
name, #: as !nil
|
|
86
|
+
)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
#: (String from, String to) -> void
|
|
90
|
+
def add_alias(from, to)
|
|
91
|
+
aliases[from] = to unless aliases[from]
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
#: -> Array[String]
|
|
95
|
+
def command_names
|
|
96
|
+
@contextual_resolver.command_names + commands.keys
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
#: (String name) -> bool
|
|
100
|
+
def exist?(name)
|
|
101
|
+
!resolve_command(name).first.nil?
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
private
|
|
105
|
+
|
|
106
|
+
#: (String name) -> String
|
|
107
|
+
def resolve_alias(name)
|
|
108
|
+
aliases[name] || @contextual_resolver.aliases.fetch(name, name)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
#: (String name) -> [singleton(CLI::Kit::BaseCommand)?, String]
|
|
112
|
+
def resolve_command(name)
|
|
113
|
+
name = resolve_alias(name)
|
|
114
|
+
resolve_global_command(name) ||
|
|
115
|
+
resolve_contextual_command(name) ||
|
|
116
|
+
[nil, name]
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
#: (String name) -> [singleton(CLI::Kit::BaseCommand), String]?
|
|
120
|
+
def resolve_global_command(name)
|
|
121
|
+
klass = resolve_class(commands.fetch(name, nil))
|
|
122
|
+
return unless klass
|
|
123
|
+
|
|
124
|
+
[klass, name]
|
|
125
|
+
rescue NameError
|
|
126
|
+
nil
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
#: (String name) -> [singleton(CLI::Kit::BaseCommand), String]?
|
|
130
|
+
def resolve_contextual_command(name)
|
|
131
|
+
found = @contextual_resolver.command_names.include?(name)
|
|
132
|
+
return unless found
|
|
133
|
+
|
|
134
|
+
[@contextual_resolver.command_class(name), name]
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
#: (command_or_proc? class_or_proc) -> singleton(CLI::Kit::BaseCommand)?
|
|
138
|
+
def resolve_class(class_or_proc)
|
|
139
|
+
case class_or_proc
|
|
140
|
+
when nil
|
|
141
|
+
nil
|
|
142
|
+
when Proc
|
|
143
|
+
class_or_proc.call
|
|
144
|
+
else
|
|
145
|
+
class_or_proc
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
end
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
|
|
3
|
+
require 'cli/kit'
|
|
4
|
+
require 'fileutils'
|
|
5
|
+
|
|
6
|
+
module CLI
|
|
7
|
+
module Kit
|
|
8
|
+
class Config
|
|
9
|
+
XDG_CONFIG_HOME = 'XDG_CONFIG_HOME'
|
|
10
|
+
|
|
11
|
+
#: (tool_name: String) -> void
|
|
12
|
+
def initialize(tool_name:)
|
|
13
|
+
@tool_name = tool_name
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Returns the config corresponding to `name` from the config file
|
|
17
|
+
# `false` is returned if it doesn't exist
|
|
18
|
+
#
|
|
19
|
+
# #### Parameters
|
|
20
|
+
# `section` : the section of the config value you are looking for
|
|
21
|
+
# `name` : the name of the config value you are looking for
|
|
22
|
+
#
|
|
23
|
+
# #### Returns
|
|
24
|
+
# `value` : the value of the config variable (nil if none)
|
|
25
|
+
#
|
|
26
|
+
# #### Example Usage
|
|
27
|
+
# `config.get('name.of.config')`
|
|
28
|
+
#
|
|
29
|
+
#: (String section, String name, ?default: String?) -> String?
|
|
30
|
+
def get(section, name, default: nil)
|
|
31
|
+
all_configs.dig("[#{section}]", name) || default
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Coalesce and enforce the value of a config to a boolean
|
|
35
|
+
#: (String section, String name, ?default: bool?) -> bool?
|
|
36
|
+
def get_bool(section, name, default: false)
|
|
37
|
+
case get(section, name)
|
|
38
|
+
when 'true'
|
|
39
|
+
true
|
|
40
|
+
when 'false'
|
|
41
|
+
false
|
|
42
|
+
when nil
|
|
43
|
+
default
|
|
44
|
+
else
|
|
45
|
+
raise CLI::Kit::Abort, "Invalid config: #{section}.#{name} is expected to be true or false"
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Sets the config value in the config file
|
|
50
|
+
#
|
|
51
|
+
# #### Parameters
|
|
52
|
+
# `section` : the section of the config you are setting
|
|
53
|
+
# `name` : the name of the config you are setting
|
|
54
|
+
# `value` : the value of the config you are setting
|
|
55
|
+
#
|
|
56
|
+
# #### Example Usage
|
|
57
|
+
# `config.set('section', 'name.of.config', 'value')`
|
|
58
|
+
#
|
|
59
|
+
#: (String section, String name, (String | bool)? value) -> void
|
|
60
|
+
def set(section, name, value)
|
|
61
|
+
all_configs["[#{section}]"] ||= {}
|
|
62
|
+
section = all_configs["[#{section}]"] #: as !nil
|
|
63
|
+
case value
|
|
64
|
+
when nil
|
|
65
|
+
section.delete(name)
|
|
66
|
+
else
|
|
67
|
+
section[name] = value.to_s
|
|
68
|
+
end
|
|
69
|
+
write_config
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Unsets a config value in the config file
|
|
73
|
+
#
|
|
74
|
+
# #### Parameters
|
|
75
|
+
# `section` : the section of the config you are deleting
|
|
76
|
+
# `name` : the name of the config you are deleting
|
|
77
|
+
#
|
|
78
|
+
# #### Example Usage
|
|
79
|
+
# `config.unset('section', 'name.of.config')`
|
|
80
|
+
#
|
|
81
|
+
#: (String section, String name) -> void
|
|
82
|
+
def unset(section, name)
|
|
83
|
+
set(section, name, nil)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Gets the hash for the entire section
|
|
87
|
+
#
|
|
88
|
+
# #### Parameters
|
|
89
|
+
# `section` : the section of the config you are getting
|
|
90
|
+
#
|
|
91
|
+
# #### Example Usage
|
|
92
|
+
# `config.get_section('section')`
|
|
93
|
+
#
|
|
94
|
+
#: (String section) -> Hash[String, String]
|
|
95
|
+
def get_section(section)
|
|
96
|
+
(all_configs["[#{section}]"] || {}).dup
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
#: -> String
|
|
100
|
+
def to_s
|
|
101
|
+
ini.to_s
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# The path on disk at which the configuration is stored:
|
|
105
|
+
# `$XDG_CONFIG_HOME/<toolname>/config`
|
|
106
|
+
# if ENV['XDG_CONFIG_HOME'] is not set, we default to ~/.config, e.g.:
|
|
107
|
+
# ~/.config/tool/config
|
|
108
|
+
#
|
|
109
|
+
#: -> String
|
|
110
|
+
def file
|
|
111
|
+
config_home = ENV.fetch(XDG_CONFIG_HOME, '~/.config')
|
|
112
|
+
File.expand_path(File.join(@tool_name, 'config'), config_home)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
private
|
|
116
|
+
|
|
117
|
+
#: -> Hash[String, Hash[String, String]]
|
|
118
|
+
def all_configs
|
|
119
|
+
ini.ini
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
#: -> CLI::Kit::Ini
|
|
123
|
+
def ini
|
|
124
|
+
@ini ||= CLI::Kit::Ini.new(file).tap(&:parse)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
#: -> void
|
|
128
|
+
def write_config
|
|
129
|
+
all_configs.each do |section, sub_config|
|
|
130
|
+
all_configs.delete(section) if sub_config.empty?
|
|
131
|
+
end
|
|
132
|
+
FileUtils.mkdir_p(File.dirname(file))
|
|
133
|
+
File.write(file, to_s)
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
class Exception
|
|
5
|
+
# You'd think instance variables @bug and @silent would work here. They
|
|
6
|
+
# don't. I'm not sure why. If you, the reader, want to take some time to
|
|
7
|
+
# figure it out, go ahead and refactor to that.
|
|
8
|
+
|
|
9
|
+
#: -> bool
|
|
10
|
+
def bug?
|
|
11
|
+
true
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
#: -> bool
|
|
15
|
+
def silent?
|
|
16
|
+
false
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
#: (?bool bug) -> void
|
|
20
|
+
def bug!(bug = true)
|
|
21
|
+
singleton_class.define_method(:bug?) { bug }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
#: (?bool silent) -> void
|
|
25
|
+
def silent!(silent = true)
|
|
26
|
+
singleton_class.define_method(:silent?) { silent }
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
|
|
3
|
+
require 'cli/kit'
|
|
4
|
+
require 'English'
|
|
5
|
+
|
|
6
|
+
module CLI
|
|
7
|
+
module Kit
|
|
8
|
+
class ErrorHandler
|
|
9
|
+
#: type exception_reporter_or_proc = singleton(ExceptionReporter) | ^() -> singleton(ExceptionReporter)
|
|
10
|
+
|
|
11
|
+
#: ^(Exception arg0) -> Integer
|
|
12
|
+
attr_writer :override_exception_handler
|
|
13
|
+
|
|
14
|
+
#: (?log_file: String?, ?exception_reporter: exception_reporter_or_proc, ?tool_name: String?, ?dev_mode: bool) -> void
|
|
15
|
+
def initialize(log_file: nil, exception_reporter: NullExceptionReporter, tool_name: nil, dev_mode: false)
|
|
16
|
+
@log_file = log_file
|
|
17
|
+
@exception_reporter_or_proc = exception_reporter
|
|
18
|
+
@tool_name = tool_name
|
|
19
|
+
@dev_mode = dev_mode
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# @abstract
|
|
23
|
+
class ExceptionReporter
|
|
24
|
+
class << self
|
|
25
|
+
# @abstract
|
|
26
|
+
#: (Exception?, ?String?) -> void
|
|
27
|
+
def report(exception, logs = nil)
|
|
28
|
+
raise(NotImplementedError)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
class NullExceptionReporter < ExceptionReporter
|
|
34
|
+
class << self
|
|
35
|
+
# @override
|
|
36
|
+
#: (Exception? _exception, ?String? _logs) -> void
|
|
37
|
+
def report(_exception, _logs = nil)
|
|
38
|
+
nil
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
#: { -> void } -> Integer
|
|
44
|
+
def call(&block)
|
|
45
|
+
# @at_exit_exception is set if handle_abort decides to submit an error.
|
|
46
|
+
# $ERROR_INFO is set if we terminate because of a signal.
|
|
47
|
+
at_exit { report_exception(@at_exit_exception || $ERROR_INFO) }
|
|
48
|
+
triage_all_exceptions(&block)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
#: (Exception? error) -> void
|
|
52
|
+
def report_exception(error)
|
|
53
|
+
if (notify_with = exception_for_submission(error))
|
|
54
|
+
logs = nil
|
|
55
|
+
if @log_file
|
|
56
|
+
logs = begin
|
|
57
|
+
File.read(@log_file)
|
|
58
|
+
rescue => e
|
|
59
|
+
"(#{e.class}: #{e.message})"
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
exception_reporter.report(notify_with, logs)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
SIGNALS_THAT_ARENT_BUGS = [
|
|
67
|
+
'SIGTERM', 'SIGHUP', 'SIGINT',
|
|
68
|
+
].freeze
|
|
69
|
+
|
|
70
|
+
private
|
|
71
|
+
|
|
72
|
+
# Run the program, handling any errors that occur.
|
|
73
|
+
#
|
|
74
|
+
# Errors are printed to stderr unless they're #silent?, and are reported
|
|
75
|
+
# to bugsnag (by setting @at_exit_exeption for our at_exit handler) if
|
|
76
|
+
# they're #bug?
|
|
77
|
+
#
|
|
78
|
+
# Returns an exit status for the program.
|
|
79
|
+
#: { -> void } -> Integer
|
|
80
|
+
def triage_all_exceptions(&block)
|
|
81
|
+
begin
|
|
82
|
+
block.call
|
|
83
|
+
CLI::Kit::EXIT_SUCCESS
|
|
84
|
+
rescue Interrupt => e # Ctrl-C
|
|
85
|
+
# transform message, prevent bugsnag
|
|
86
|
+
exc = e.exception('Interrupt')
|
|
87
|
+
CLI::Kit.raise(exc, bug: false)
|
|
88
|
+
rescue Errno::ENOSPC => e
|
|
89
|
+
# transform message, prevent bugsnag
|
|
90
|
+
message = if @tool_name
|
|
91
|
+
"Your disk is full - {{command:#{@tool_name}}} requires free space to operate"
|
|
92
|
+
else
|
|
93
|
+
'Your disk is full - free space is required to operate'
|
|
94
|
+
end
|
|
95
|
+
exc = e.exception(message)
|
|
96
|
+
CLI::Kit.raise(exc, bug: false)
|
|
97
|
+
end
|
|
98
|
+
# If SystemExit was raised, e.g. `exit()`, then
|
|
99
|
+
# return whatever status is attached to the exception
|
|
100
|
+
# object. The special exit statuses have already been
|
|
101
|
+
# handled below.
|
|
102
|
+
rescue SystemExit => e
|
|
103
|
+
e.status
|
|
104
|
+
rescue Exception => e # rubocop:disable Lint/RescueException
|
|
105
|
+
@at_exit_exception = e if e.bug?
|
|
106
|
+
|
|
107
|
+
if (eh = @override_exception_handler)
|
|
108
|
+
return eh.call(e)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
raise(e) if @dev_mode && e.bug?
|
|
112
|
+
|
|
113
|
+
stderr_puts(e.message) unless e.silent?
|
|
114
|
+
e.bug? ? CLI::Kit::EXIT_BUG : CLI::Kit::EXIT_FAILURE_BUT_NOT_BUG
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
#: (Exception? error) -> Exception?
|
|
118
|
+
def exception_for_submission(error)
|
|
119
|
+
# happens on normal non-error termination
|
|
120
|
+
return if error.nil?
|
|
121
|
+
|
|
122
|
+
return unless error.bug?
|
|
123
|
+
|
|
124
|
+
case error
|
|
125
|
+
when SignalException
|
|
126
|
+
SIGNALS_THAT_ARENT_BUGS.include?(error.message) ? nil : error
|
|
127
|
+
when SystemExit # "exit N" called
|
|
128
|
+
case error.status
|
|
129
|
+
when CLI::Kit::EXIT_SUCCESS # submit nothing if it was `exit 0`
|
|
130
|
+
nil
|
|
131
|
+
when CLI::Kit::EXIT_FAILURE_BUT_NOT_BUG
|
|
132
|
+
# if it was `exit 30`, translate the exit code to 1, and submit
|
|
133
|
+
# nothing. 30 is used to signal normal failures that are not
|
|
134
|
+
# indicative of bugs. However, users should see it presented as 1.
|
|
135
|
+
exit(1)
|
|
136
|
+
else
|
|
137
|
+
# don't treat this as an exception, simply reraise.
|
|
138
|
+
# this is indicative of `exit` being called with a
|
|
139
|
+
# non-zero number, and the requested exit status
|
|
140
|
+
# needs to be maintained.
|
|
141
|
+
exit(error.status)
|
|
142
|
+
end
|
|
143
|
+
else
|
|
144
|
+
error
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
#: (String message) -> void
|
|
149
|
+
def stderr_puts(message)
|
|
150
|
+
$stderr.puts(CLI::UI.fmt("{{red:#{message}}}"))
|
|
151
|
+
rescue Errno::EPIPE, Errno::EIO
|
|
152
|
+
nil
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
#: -> singleton(ExceptionReporter)
|
|
156
|
+
def exception_reporter
|
|
157
|
+
case @exception_reporter_or_proc
|
|
158
|
+
when Proc
|
|
159
|
+
@exception_reporter_or_proc.call
|
|
160
|
+
else
|
|
161
|
+
@exception_reporter_or_proc
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
|
|
3
|
+
require 'cli/kit'
|
|
4
|
+
require 'English'
|
|
5
|
+
require 'fileutils'
|
|
6
|
+
|
|
7
|
+
module CLI
|
|
8
|
+
module Kit
|
|
9
|
+
class Executor
|
|
10
|
+
#: (log_file: String) -> void
|
|
11
|
+
def initialize(log_file:)
|
|
12
|
+
FileUtils.mkpath(File.dirname(log_file))
|
|
13
|
+
@log_file = log_file
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
#: (singleton(CLI::Kit::BaseCommand) command, String command_name, Array[String] args) -> void
|
|
17
|
+
def call(command, command_name, args)
|
|
18
|
+
with_traps do
|
|
19
|
+
with_logging do |id|
|
|
20
|
+
command.call(args, command_name)
|
|
21
|
+
rescue => e
|
|
22
|
+
begin
|
|
23
|
+
$stderr.puts "This command ran with ID: #{id}"
|
|
24
|
+
$stderr.puts 'Please include this information in any issues/report along with relevant logs'
|
|
25
|
+
rescue SystemCallError
|
|
26
|
+
# Outputting to stderr is best-effort. Avoid raising another error when outputting debug info so that
|
|
27
|
+
# we can detect and log the original error, which may even be the source of this error.
|
|
28
|
+
nil
|
|
29
|
+
end
|
|
30
|
+
raise e
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
#: [T] { (String id) -> T } -> T
|
|
38
|
+
def with_logging(&block)
|
|
39
|
+
CLI::UI.log_output_to(@log_file) do
|
|
40
|
+
CLI::UI::StdoutRouter.with_id(on_streams: [CLI::UI::StdoutRouter.duplicate_output_to].compact) do |id|
|
|
41
|
+
block.call(id)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
#: [T] { -> T } -> T
|
|
47
|
+
def with_traps(&block)
|
|
48
|
+
twrap('QUIT', method(:quit_handler)) do
|
|
49
|
+
twrap('INFO', method(:info_handler), &block)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
#: [T] (String signal, Method handler) { -> T } -> T
|
|
54
|
+
def twrap(signal, handler, &block)
|
|
55
|
+
return yield unless Signal.list.key?(signal)
|
|
56
|
+
|
|
57
|
+
begin
|
|
58
|
+
begin
|
|
59
|
+
prev_handler = trap(signal, handler)
|
|
60
|
+
installed = true
|
|
61
|
+
rescue ArgumentError
|
|
62
|
+
# If we couldn't install a signal handler because the signal is
|
|
63
|
+
# reserved, remember not to uninstall it later.
|
|
64
|
+
installed = false
|
|
65
|
+
end
|
|
66
|
+
yield
|
|
67
|
+
ensure
|
|
68
|
+
trap(signal, prev_handler) if installed
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
#: (untyped _sig) -> void
|
|
73
|
+
def quit_handler(_sig)
|
|
74
|
+
z = caller
|
|
75
|
+
CLI::UI.raw do
|
|
76
|
+
$stderr.puts('SIGQUIT: quit')
|
|
77
|
+
$stderr.puts(z)
|
|
78
|
+
end
|
|
79
|
+
exit(CLI::Kit::EXIT_FAILURE_BUT_NOT_BUG)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
#: (untyped _sig) -> void
|
|
83
|
+
def info_handler(_sig)
|
|
84
|
+
z = caller
|
|
85
|
+
CLI::UI.raw do
|
|
86
|
+
$stderr.puts('SIGINFO:')
|
|
87
|
+
$stderr.puts(z)
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
|
|
3
|
+
require 'cli/kit'
|
|
4
|
+
|
|
5
|
+
module CLI
|
|
6
|
+
module Kit
|
|
7
|
+
# INI is a language similar to JSON or YAML, but simplied
|
|
8
|
+
# The spec is here: https://en.wikipedia.org/wiki/INI_file
|
|
9
|
+
# This parser includes supports for 2 very basic uses
|
|
10
|
+
# - Sections
|
|
11
|
+
# - Key Value Pairs (within and outside of the sections)
|
|
12
|
+
#
|
|
13
|
+
# [global]
|
|
14
|
+
# key = val
|
|
15
|
+
#
|
|
16
|
+
# Nothing else is supported right now
|
|
17
|
+
# See the ini_test.rb file for more examples
|
|
18
|
+
#
|
|
19
|
+
class Ini
|
|
20
|
+
#: Hash[String, Hash[String, String]]
|
|
21
|
+
attr_accessor :ini
|
|
22
|
+
|
|
23
|
+
#: (?String? path, ?config: String?, ?default_section: String) -> void
|
|
24
|
+
def initialize(path = nil, config: nil, default_section: '[global]')
|
|
25
|
+
@config = if path && File.exist?(path)
|
|
26
|
+
File.readlines(path)
|
|
27
|
+
elsif config
|
|
28
|
+
config.lines
|
|
29
|
+
end
|
|
30
|
+
@ini = {}
|
|
31
|
+
@current_key = default_section
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
#: -> Hash[String, Hash[String, String]]
|
|
35
|
+
def parse
|
|
36
|
+
return @ini if @config.nil?
|
|
37
|
+
|
|
38
|
+
@config.each do |l|
|
|
39
|
+
l.strip!
|
|
40
|
+
|
|
41
|
+
if section_designator?(l)
|
|
42
|
+
@current_key = l
|
|
43
|
+
else
|
|
44
|
+
k, v = l.split('=', 2).map(&:strip)
|
|
45
|
+
set_val(k, v) if k && v
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
@ini
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
#: -> String
|
|
53
|
+
def git_format
|
|
54
|
+
to_ini(git_format: true)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
#: -> String
|
|
58
|
+
def to_s
|
|
59
|
+
to_ini
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
private
|
|
63
|
+
|
|
64
|
+
#: (?git_format: bool) -> String
|
|
65
|
+
def to_ini(git_format: false)
|
|
66
|
+
optional_tab = git_format ? "\t" : ''
|
|
67
|
+
str = []
|
|
68
|
+
@ini.each do |section_designator, section|
|
|
69
|
+
str << '' unless str.empty? || git_format
|
|
70
|
+
str << section_designator
|
|
71
|
+
section.each do |k, v|
|
|
72
|
+
str << "#{optional_tab}#{k} = #{v}"
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
str.join("\n")
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
#: (String key, String val) -> void
|
|
79
|
+
def set_val(key, val)
|
|
80
|
+
current_key = @current_key
|
|
81
|
+
@ini[current_key] ||= {}
|
|
82
|
+
@ini[current_key][key] = val
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
#: (String k) -> bool
|
|
86
|
+
def section_designator?(k)
|
|
87
|
+
k.start_with?('[') && k.end_with?(']')
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|