Interview Prep/Python for DevOps/Automation scripting & CLI design

A teammate keeps adding flags to a single script until it has 34 options. How do you restructure it?

IntermediateScenarioAutomation scripting & CLI design
Answer

Situation read → One script is doing several jobs; options interact in confusing ways.

What I'd do →

  1. Group functionality into subcommands (tool snapshots cleanup, tool ec2 audit) with a click group.
  2. Move shared options (profile, region, verbosity, format) to the group level and pass them via ctx.obj.
  3. Put rarely changed settings in a config file with env-var overrides.
  4. Split the code into modules per subcommand, with a thin CLI layer.

Why → Subcommands make the help text navigable and isolate options that only make sense together.

Interview tip → Mention that kubectl and aws are the model: verb/noun subcommands with global flags.

All Python for DevOps questions Roadmap: Python for automation

More on Automation scripting & CLI design