Skip to main content

Crate tryme_core

Crate tryme_core 

Source
Expand description

Core library for try-me-maybe — a Rust port of tobi/try.

try is a script emitter with an interactive picker attached: a child process cannot cd its parent shell, so the TUI renders to stderr, the chosen action is emitted as a shell script on stdout, and the wrapper function (emitted by tryme init) evals stdout on exit 0.

Everything test-observable lives in this crate; the tryme binary is a thin wrapper. Conformance target: tobi/try v1.9.3, pinned by the adopted suite at spec/tests/ (see spec/UPSTREAM).

§Provenance

Decisions are recorded in docs/adr/. Behavior authority order (ADR-0003): upstream try.rb code > shipped spec/tests > prose specs.

Re-exports§

pub use dispatch::run;
pub use dispatch::Ctx;
pub use emit::ScriptOut;
pub use env::Env;

Modules§

argv
Argv normalization — a direct port of upstream’s ARGV surgery (try.rb:1008-1092). clap cannot model this (flags anywhere, last-wins --path, unknown tokens becoming the query), so the declaration in the binary’s cli module is interface-only and this module is the runtime parser. An inventory-diff unit test chains the two.
dispatch
Command dispatch — port of the __FILE__ == $0 driver (try.rb:1008-1587): flag extraction, the command case tree, and the exit-code contract (0 = script emitted, 1 = cancel/error, 2 = bare help).
emit
Script emission — the ONLY module that writes to stdout.
env
Environment snapshot — the only place process env is read.
fuzzy
Fuzzy matcher — exact transliteration of upstream lib/fuzzy.rb.
giturl
Git URI parsing — port of parse_git_uri / is_git_uri? / generate_clone_directory_name (try.rb:1039-1078).
help
Global help text — byte-for-byte port of print_global_help (try.rb:960-1006), with one sanctioned substitution: the version token renders this package’s version (ADR-0002). Printed to STDERR.
naming
Directory naming — port of unique_dir_name, resolve_unique_name_with_versioning, and worktree_path (try.rb:1469-1523). Pinned by test_33_versioning.sh.
scan
Directory scan — port of load_all_tries (try.rb:94-136).
scripts
Script builders — ports of script_cd / script_mkdir_cd / script_clone / script_worktree / script_delete / script_ascend / script_rename (try.rb:1411-1467). Every byte matters: the emitted strings are pinned by test_05/07/12/16/31/37.
selector
Interactive selector — port of TrySelector (try.rb:10-953).
testkeys
--and-keys parser — port of parse_test_keys (try.rb:1094-1150).
tui
TUI toolkit — structural port of upstream lib/tui.rb.
wrappers
Shell integration — ports of init_snippet, detect_shell, shell_rc_file, fish? (try.rb:1230-1313, 1503-1510) and Ruby’s File.expand_path semantics.