Module: SplttyCLI

Defined in:
lib/spltty_cli.rb,
lib/spltty_cli/notes.rb,
lib/spltty_cli/table.rb,
lib/spltty_cli/config.rb,
lib/spltty_cli/groups.rb,
lib/spltty_cli/ledger.rb,
lib/spltty_cli/prompt.rb,
lib/spltty_cli/totals.rb,
lib/spltty_cli/version.rb,
lib/spltty_cli/discovery.rb,
lib/spltty_cli/notes_sync.rb,
lib/spltty_cli/commands/add.rb,
lib/spltty_cli/commands/help.rb,
lib/spltty_cli/commands/list.rb,
lib/spltty_cli/commands/sync.rb,
lib/spltty_cli/commands/groups.rb,
lib/spltty_cli/commands/settle.rb,
lib/spltty_cli/commands/totals.rb,
lib/spltty_cli/commands/install.rb,
lib/spltty_cli/commands/methods.rb,
lib/spltty_cli/commands/groups_rm.rb,
lib/spltty_cli/commands/groups_add.rb,
lib/spltty_cli/commands/methods_add.rb

Defined Under Namespace

Modules: CLI, Commands, Discovery, Groups, Ledger, Notes, NotesSync, Prompt, Table, Totals Classes: Config

Constant Summary collapse

TEMPLATES_DIR =

Files bundled with the gem: the workspace CLAUDE.md template, the per-ledger notes header, the source index, and the /ingest skill.

File.expand_path("../templates", __dir__)
COMMAND_SPECS =

Single source of truth for commands; used both to register with dry-cli and to render spltty help.

[
  { name: "install",     klass: Commands::Install },
  { name: "add",         klass: Commands::Add },
  { name: "list",        klass: Commands::List },
  { name: "sync",        klass: Commands::Sync },
  { name: "totals",      klass: Commands::Totals },
  { name: "settle",      klass: Commands::Settle },
  { name: "groups",      klass: Commands::Groups },
  { name: "groups add",  klass: Commands::GroupsAdd },
  { name: "groups rm",   klass: Commands::GroupsRm },
  { name: "methods",     klass: Commands::Methods },
  { name: "methods add", klass: Commands::MethodsAdd },
  { name: "help",        klass: Commands::Help },
].freeze
VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.load_config(opts) ⇒ Object

Load the config for the workspace this command is running against, honoring --accounts-dir / SPLTTY_ACCOUNTS_DIR. Resolution order for the config path:

1. --config / -C
2. SPLTTY_CONFIG
3. the nearest .spltty/config.json walking up from the cwd

With none of those, there is no workspace here — every command except install errors out rather than silently inventing an empty config.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/spltty_cli.rb', line 61

def self.load_config(opts)
  path = opts[:config] || ENV["SPLTTY_CONFIG"]
  path ||= Config.discover(Dir.pwd)
  unless path
    raise Config::Error,
          "no spltty workspace found in #{Dir.pwd} or any parent directory — " \
          "run `spltty install` to create one (or pass --config PATH)"
  end

  config = Config.load(path)
  override = opts[:accounts_dir] || ENV["SPLTTY_ACCOUNTS_DIR"]
  config.accounts_dir = File.expand_path(override) if override && !override.empty?
  config
end

.run(argv = ARGV) ⇒ Object

Entrypoint shared by exe/spltty (gem binary) and bin/spltty (mise launcher).

-pr is normalized before dry-cli parses it: dry-cli would otherwise read -pr X as -p r (bundled short flags). Maps to the real --paid-responsible option, supporting both -pr X and -pr=X.



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/spltty_cli.rb', line 38

def self.run(argv = ARGV)
  $PROGRAM_NAME = "spltty"
  normalized = argv.map do |arg|
    if arg == "-pr"
      "--paid-responsible"
    elsif arg.start_with?("-pr=")
      "--paid-responsible=#{arg[4..]}"
    else
      arg
    end
  end
  Dry::CLI.new(CLI).call(arguments: normalized)
end