Acme-Claude-Shell
view release on metacpan or search on metacpan
bin/acme_claude_shell view on Meta::CPAN
#!/usr/bin/env perl
use 5.020;
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../lib";
use Acme::Claude::Shell qw(shell run);
use Getopt::Long;
use Term::ANSIColor qw(colored);
use Pod::Usage;
our $VERSION = '0.01';
my %opts = (
'dry-run' => 0,
'safe-mode' => 1,
'color' => -t STDOUT ? 1 : 0,
'dir' => '.',
);
GetOptions(
'dry-run|n' => \$opts{'dry-run'},
'unsafe|u' => sub { $opts{'safe-mode'} = 0 },
'no-color' => sub { $opts{'color'} = 0 },
'color!' => \$opts{'color'},
'directory|d=s' => \$opts{'dir'},
'command|c=s' => \$opts{'command'},
'model|m=s' => \$opts{'model'},
'help|h' => \$opts{'help'},
'version|v' => \$opts{'version'},
) or pod2usage(2);
if ($opts{'help'}) {
show_help();
exit 0;
}
if ($opts{'version'}) {
show_version();
exit 0;
}
# Check for piped input: acme_claude_shell -c - reads from stdin
my $command = $opts{'command'};
if (defined $command && $command eq '-') {
# Read command from stdin (for piping: echo "list files" | acme_claude_shell -c -)
local $/;
$command = <STDIN>;
chomp $command if defined $command;
}
# Single command mode or interactive
if (defined $command && length $command) {
run($command,
dry_run => $opts{'dry-run'},
safe_mode => $opts{'safe-mode'},
working_dir => $opts{'dir'},
colorful => $opts{'color'},
($opts{'model'} ? (model => $opts{'model'}) : ()),
);
} else {
shell(
dry_run => $opts{'dry-run'},
safe_mode => $opts{'safe-mode'},
working_dir => $opts{'dir'},
colorful => $opts{'color'},
($opts{'model'} ? (model => $opts{'model'}) : ()),
);
}
sub show_help {
my $c = $opts{'color'};
if ($c) {
print colored(['bold', 'cyan'], "\n Acme::Claude::Shell"), " - AI-powered interactive shell\n\n";
} else {
print "\n Acme::Claude::Shell - AI-powered interactive shell\n\n";
}
print_section("Usage", $c);
print " acme_claude_shell [options]\n";
print " acme_claude_shell -c \"find all large log files\"\n\n";
print_section("Options", $c);
print_opt("-n, --dry-run", "Preview mode - show commands without executing", $c);
print_opt("-u, --unsafe", "Disable safety confirmations for dangerous commands", $c);
print_opt("--no-color", "Disable colored output", $c);
print_opt("-d, --directory DIR", "Set working directory (default: current)", $c);
print_opt("-c, --command CMD", "Run single command and exit (use '-' for stdin)", $c);
print_opt("-m, --model MODEL", "Claude model to use (e.g., claude-opus-4-5)", $c);
print_opt("-h, --help", "Show this help", $c);
print_opt("-v, --version", "Show version", $c);
print "\n";
print_section("Examples", $c);
print " acme_claude_shell # Start interactive shell\n";
print " acme_claude_shell --dry-run # Preview mode\n";
print " acme_claude_shell -d /var/log # Start in specific directory\n";
print " acme_claude_shell -c \"list perl files\" # Single command\n";
print " acme_claude_shell -m claude-opus-4-5 # Use a specific model\n";
print " echo \"list files\" | acme_claude_shell -c - # Piped input\n\n";
print_section("Interactive Commands", $c);
print " help Show help inside the shell\n";
print " history Show executed command history\n";
print " clear Clear the screen\n";
print " exit Exit the shell (or 'quit')\n\n";
print_section("Example Session", $c);
if ($c) {
print colored(['green'], " acme_claude_shell> "), "find all perl files larger than 10k\n";
print colored(['cyan'], " Thinking...\n");
print " I'll find .pl and .pm files over 10KB:\n\n";
( run in 1.315 second using v1.01-cache-2.11-cpan-140bd7fdf52 )