Class: Diogenes::Cli
- Inherits:
-
Object
- Object
- Diogenes::Cli
- Defined in:
- lib/diogenes/cli.rb,
lib/diogenes/cli/init.rb,
lib/diogenes/cli/build.rb,
lib/diogenes/cli/watch.rb,
lib/diogenes/cli/evaluate.rb,
lib/diogenes/cli/validate.rb,
sig/generated/diogenes/cli.rbs,
sig/generated/diogenes/cli/init.rbs,
sig/generated/diogenes/cli/build.rbs,
sig/generated/diogenes/cli/evaluate.rbs
Defined Under Namespace
Classes: Build, Evaluate, Init, Validate, Watch
Constant Summary collapse
- COMMANDS =
{ "init" => Init, "build" => Build, "evaluate" => Evaluate, "validate" => Validate, "watch" => Watch }.freeze
Class Method Summary collapse
-
.run(argv = ARGV, out: $stdout, err: $stderr, **opts) ⇒ Integer
: (?Array argv, ?out: IO, ?err: IO, **untyped) -> Integer.
Instance Method Summary collapse
-
#initialize(argv:, out:, err:, **opts) ⇒ Cli
constructor
: (argv: Array, out: IO, err: IO, **untyped) -> void.
-
#print_help ⇒ Integer
: () -> Integer.
-
#print_version ⇒ Integer
: () -> Integer.
-
#run ⇒ Integer
: () -> Integer.
-
#run_command(command_class, args) ⇒ Integer
: (Class, Array) -> Integer.
-
#unknown_command_message(command) ⇒ String
Print the unknown command message -- : (String) -> String.
Constructor Details
#initialize(argv:, out:, err:, **opts) ⇒ Cli
: (argv: Array, out: IO, err: IO, **untyped) -> void
26 27 28 29 30 31 32 |
# File 'lib/diogenes/cli.rb', line 26 def initialize(argv:, out:, err:, **opts) @argv = argv.dup #: Array[String] @out = out #: IO @err = err #: IO @in = opts.fetch(:in, $stdin) #: IO @cwd = opts.fetch(:cwd, Dir.pwd) #: String end |
Class Method Details
.run(argv = ARGV, out: $stdout, err: $stderr, **opts) ⇒ Integer
: (?Array argv, ?out: IO, ?err: IO, **untyped) -> Integer
21 22 23 |
# File 'lib/diogenes/cli.rb', line 21 def self.run(argv = ARGV, out: $stdout, err: $stderr, **opts) new(argv: argv, out: out, err: err, **opts).run end |
Instance Method Details
#print_help ⇒ Integer
: () -> Integer
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/diogenes/cli.rb', line 62 def print_help @out.puts <<~HELP Diogenes - The Ruby AI Feature Gatekeeper Usage: diogenes <command> [options] Description: Diogenes is a Ruby gem that holds your AI features to the same light. It has two jobs: 1. A five-gate gauntlet decision framework that determines whether something should be an AI feature in production, or whether it's a software problem in disguise. Derived from Ruby's core principles: least surprise, programmer happiness, and human-centered design. 2. An agent configuration build tool that lets you write your AI agent skills, rules, and hooks once in a canonical Ruby DSL, and Diogenes builds the right configuration for every agent you use: Claude Code, Cursor, Copilot, Codex, Gemini, and more. Commands: init Initialize a new Diogenes project build Build the Diogenes agent configuration for a given target evaluate Evaluate a proposed AI feature through the five gates validate Validate the Diogenes agent configuration for a given target watch Watch .diogenes/ and rebuild on changes help Show help for a command version Show version information HELP 0 end |
#print_version ⇒ Integer
: () -> Integer
87 88 89 90 |
# File 'lib/diogenes/cli.rb', line 87 def print_version @out.puts(Diogenes::VERSION) 0 end |
#run ⇒ Integer
: () -> Integer
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/diogenes/cli.rb', line 35 def run command, *args = @argv case command when nil, "help", "-h", "--help" print_help when "version", "-v", "--version" print_version when *COMMANDS.keys run_command(COMMANDS.fetch(command), args) else raise UserError, (command) end rescue OptionParser::ParseError, UserError => e @err.puts e. 1 end |
#run_command(command_class, args) ⇒ Integer
: (Class, Array) -> Integer
56 57 58 59 |
# File 'lib/diogenes/cli.rb', line 56 def run_command(command_class, args) opts = {in: @in, cwd: @cwd} command_class.run(argv: args, cwd: @cwd, out: @out, err: @err, **opts) end |
#unknown_command_message(command) ⇒ String
Print the unknown command message
: (String) -> String
95 96 97 98 99 100 101 |
# File 'lib/diogenes/cli.rb', line 95 def (command) <<~MESSAGE.strip Unknown command: #{command} Run `diogenes help` to see available commands. MESSAGE end |