Skip to content

Add batch/non-interactive CLI mode to Perl and Python ssl-admin#12

Open
ecrist wants to merge 2 commits intomasterfrom
feature/batch-mode
Open

Add batch/non-interactive CLI mode to Perl and Python ssl-admin#12
ecrist wants to merge 2 commits intomasterfrom
feature/batch-mode

Conversation

@ecrist
Copy link
Copy Markdown
Owner

@ecrist ecrist commented Mar 14, 2026

Summary

  • Adds full non-interactive batch mode to both the Python and Perl ssl-admin implementations
  • Introduces 15 subcommands mapping to every interactive menu item (create-sign, revoke, gen-crl, server, options, etc.) plus the legacy crl alias
  • Central yn_prompt_or_default() helper returns preset values in batch mode or falls back to interactive prompts — minimal diff against existing menu logic
  • Sleeps and recursive main_menu() calls are suppressed in batch mode so scripts exit cleanly
  • Python: uses argparse with subparsers; parser built once and reused for --help and dispatch
  • Perl: uses Getopt::Long with positional command extraction via splice

Example usage

ssl-admin create-sign --cn jdoe
ssl-admin revoke --cn jdoe
ssl-admin server --cn webserver --overwrite
ssl-admin options --days 730 --size 4096
ssl-admin gen-crl
ssl-admin view-crl

Test plan

  • Run ssl-admin --help and ssl-admin create-sign --help — verify help text prints without requiring a config file
  • Run ssl-admin create-sign --cn testuser against an initialized CA directory — verify cert is created non-interactively
  • Run ssl-admin revoke --cn testuser — verify revocation and CRL regeneration
  • Run ssl-admin gen-crl — verify CRL is updated and script exits 0
  • Run ssl-admin create-sign --cn existing when cert exists without --overwrite — verify non-zero exit with clear error
  • Verify interactive mode is unchanged (no arguments → menu appears as before)
  • Run existing pytest suite: cd tests && pytest -v

🤖 Generated with Claude Code

Eric Crist and others added 2 commits March 13, 2026 20:50
Both implementations now accept subcommands for non-interactive use:

  ssl-admin create-sign --cn jdoe
  ssl-admin revoke --cn jdoe
  ssl-admin gen-crl
  ssl-admin server --cn webserver --overwrite
  ssl-admin options --days 730 --size 4096

Supported subcommands mirror every interactive menu item:
  options, create-csr, sign, create-sign, revoke, renew,
  view-crl, index, inline, zip, dh, new-ca, server, gen-crl
  (plus the legacy 'crl' alias)

Python uses argparse; Perl uses Getopt::Long with positional command
extraction. A central yn_prompt_or_default() helper returns preset
values in batch mode or prompts interactively otherwise. Sleeps and
recursive main_menu() calls are suppressed in batch mode.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add a Batch Mode section covering subcommands, common options, usage
examples, and a cron example for automated CRL regeneration.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant