Module: CodexNotify::Config
- Extended by:
- ConfigSupport
- Defined in:
- lib/codex_notify/config.rb
Defined Under Namespace
Constant Summary collapse
- DEFAULT_ENV_PATH =
ConfigSupport::DEFAULT_ENV_PATH
- DEFAULT_SESSIONS_DIR =
Pathname(File.('~/.codex/sessions'))
- DEFAULT_OUTBOX_DIR =
Pathname(File.('~/.codex-notify/outbox'))
Constants included from ConfigSupport
CodexNotify::ConfigSupport::DEFAULT_ENV_POLICY, CodexNotify::ConfigSupport::ENV_POLICIES, CodexNotify::ConfigSupport::REPOSITORY_ALLOWED_KEYS, CodexNotify::ConfigSupport::REPOSITORY_CREDENTIAL_PATTERN
Class Method Summary collapse
Methods included from ConfigSupport
add_common_options, apply_destination, eligible_sources, getenv_any, load_env_file, resolve_env_paths, resolve_policy, system_user_name, trusted_sources, warn_if_legacy_tool_source, warn_ignored_repository_values
Class Method Details
.build_parser ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/codex_notify/config.rb', line 46 def build_parser = Args.new( env_file: DEFAULT_ENV_PATH, env_file_explicit: false, config_file: nil, migrate_config: false, token: nil, channel: nil, destination: nil, user_name: nil, prompt: nil, title: nil, include_tools: false, throttle_sec: 1.05, sessions_dir: DEFAULT_SESSIONS_DIR.to_s, session_file: nil, poll_sec: 1.0, once: false, outbox_dir: nil, outbox_action: nil, outbox_id: nil, token_from_cli: false ) parser = OptionParser.new do |opts| opts. = 'Usage: codex-notify [options]' (opts, ) opts.on('--prompt PROMPT') { |v| .prompt = v } opts.on('--include-tools') { .include_tools = true } opts.on('--throttle-sec FLOAT', Float) { |v| .throttle_sec = v } opts.on('--sessions-dir PATH') { |v| .sessions_dir = v } opts.on('--session-file PATH') { |v| .session_file = v } opts.on('--poll-sec FLOAT', Float) { |v| .poll_sec = v } opts.on('--once') { .once = true } opts.on('--outbox-dir PATH') { |v| .outbox_dir = v } end [parser, ] end |
.parse_args(argv = nil, stderr: $stderr, legacy_checkout_root: nil) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/codex_notify/config.rb', line 86 def parse_args(argv = nil, stderr: $stderr, legacy_checkout_root: nil) parser, = build_parser parser.parse!(argv || []) return if .migrate_config ConfigDiagnostics.warn_deprecated_cli_token(stderr:) if .token_from_cli sources = EnvSourceLoader.new(legacy_checkout_root:, stderr:).load( path: .env_file, explicit: .env_file_explicit, config_path: .config_file ) policy = resolve_policy(sources, stderr:) warn_ignored_repository_values(sources, policy:, stderr:) apply_destination(, sources, policy:, stderr:) eligible = eligible_sources(sources, policy:) trusted = trusted_sources(sources) .user_name ||= eligible.lookup('CODEX_NOTIFY_USER_NAME')&.value || system_user_name .title ||= eligible.lookup('CODEX_NOTIFY_TITLE')&.value .prompt ||= eligible.lookup('CODEX_PROMPT')&.value .outbox_dir ||= trusted.lookup('CODEX_NOTIFY_OUTBOX_DIR')&.value || DEFAULT_OUTBOX_DIR.to_s rescue ConfigSupport::Error, EnvSourceLoader::Error, TrustedConfigLoader::Error, DestinationResolver::Error => e raise Error, e. end |