Should your automation tool have a CLI or a UI?
The answer: both. But build them separately.
When CLI Makes Sense
Use a CLI when:
- The tool runs on a schedule (cron jobs, cloud functions).
- The user is technical (developers, DevOps).
- You need scriptability (chaining commands together).
Example:
python process.py --file invoice.pdf --output results.xlsxThis is perfect for automation pipelines.
When UI Makes Sense
Use a UI when:
- The user is non-technical (analysts, operations).
- The task requires visual feedback (preview, progress bars).
- You need interactivity (upload files, adjust settings live).
Example: A Streamlit interface where users drag-and-drop PDFs and see results instantly.
The Best Approach: Separate Layers
Don't mix CLI logic with UI logic.
Your core processing function should look like this:
def process_file(file_path: str, output_format: str):
# ... processing logic
return resultThen build two interfaces on top:
CLI layer:
if __name__ == "__main__":
import sys
result = process_file(sys.argv[1], "xlsx")UI layer (Streamlit):
uploaded_file = st.file_uploader("Upload PDF")
if uploaded_file:
result = process_file(uploaded_file, "xlsx")
st.write(result)Same logic. Two interfaces.
My Default Pattern
I always build the CLI first.
Why? Because a CLI forces you to separate logic from UI.
Once the CLI works, adding a UI is trivial.
Conclusion
CLI for automation. UI for humans.
Build both. Keep them separate.



