How to manage arguments when implementing a Python script as a command line tool

There are two ways to use command line arguments in a standard library?

I wonder if sys.argv can simply refer to the arguments

Since it is a good idea, I will pick up some reference pages to try to implement it properly. First of all, the official document "Python 3 document"

As a general rule, the following page seems to be a good way to use ʻargparse`

Below, the process of passing a file as an argument with a pipe was written and I wanted to understand the contents, but I did not understand well that it was written one more time ...

Specifically, the following questions

When I use sys.stdin.isatty () to determine if there was a standard input ... Is the data received by the standard input included in the first argument?

There is also an execution example, but what is the key to identify the standard input value when getting the standard input value with ʻargparse.ArgumentParser (). parse_args () `...

For the time being, "process of passing a file as an argument by pipe" is not necessary for the most recently required command, so it is temporarily suspended.

The following page is a practical introductory article that describes how to write when you want to start using it quickly and how to use it frequently.

Common usage is ...

It seems that there are some modules that complement the command program other than the standard module

In addition, the following were required during the actual implementation.

Since it seems to be long, for the time being, it is the result of the investigation at the time of basic command creation, so that's all.

Recommended Posts

How to manage arguments when implementing a Python script as a command line tool
How to pass arguments when invoking python script from blender on the command line
How to receive command line arguments in Python
How to pass arguments to a Python script in SPSS Modeler Batch
How to get a string from a command line argument in python
[Python / Tkinter] How to pass arguments to command
How to run a Maya Python script
Create a command line tool to convert dollars to yen using Python
A note I looked up to make a command line tool in Python
[Python] How to test command line parser click
[Introduction to Udemy Python3 + Application] 67. Command line arguments
[Linux] [kernel module] How to pass parameters as arguments when loading a loadable kernel module
[Python] How to draw a line graph with Matplotlib
Try to make a command standby tool with python
How to execute a command using subprocess in Python
How to install NPI + send a message to line with python
How to run a Python file at a Windows 10 command prompt
How to run a Python program from within a shell script
When you want to hit a UNIX command on Python
How to write a Python class
Launch a Python script as a service
How to set Jupytext nicely when managing code as a team
[Python] How to store a csv file as one-dimensional array data
[Python] How to make a class iterable
[Python] How to convert a 2D list to a 1D list
A memo when using systemd to keep a Python script running as a daemon on CentOS 7 at all times.
When running a Python shell from Electron, pass multiple arguments to run Python.
[Python] How to invert a character string
[Ubuntu] How to execute a shell script
How to get a stacktrace in python
How to draw a vertical line on a heatmap drawn with Python seaborn
How to write a string when there are multiple lines in python
Decompose command arguments in one line in Python
How to take multiple arguments when doing parallel processing using multiprocessing in python
How to read a CSV file with Python 2/3
How to disguise a ZIP file as a PNG file
Send a message to LINE with Python (LINE Notify)
How to send a message to LINE with curl
How to create a Python virtual environment (venv)
How to open a web browser from python
How to clear tuples in a list (Python)
How to embed a variable in a python string
How to implement Discord Slash Command in Python
Let's understand how to pass arguments (Python version)
How to create a JSON file in Python
How to generate a Python object from JSON
How to add a Python module search path
Python Note: When assigning a value to a string
How to remember when you forget a word
How to notify a Discord channel in Python
How to create a shortcut command for LINUX
How to create a Kivy 1-line input box
[Python] How to draw a histogram in Matplotlib
How to output "Ketsumaimo" as standard output in Python
[Python] How to write type annotations for Callable objects treated as variables and arguments
How to use NUITKA-Utilities hinted-compilation to easily create an executable file from a Python script
How to execute sleep command, command that takes time as a test [bash, linux, mac]
How to use python multiprocessing (continued 3) apply_async in class with Pool as a member
[Grasshopper] When creating a data tree on Python script
How to create an article from the command line
How to add help to HDA (with Python script bonus)