Skip to content

Whether nargs is supported #391

@Anthony-Dong

Description

@Anthony-Dong
import argparse

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Test Cli')
    parser.add_argument('--file', '-f', dest='files', nargs='+', type=str, required=False)
    args = parser.parse_args()
    print(args)

In python, nagrs is convenient for dealing with array types, but with pflag we need to define flag repeatedly

➜  python git:(master) ✗ python main.py -f main.py init.py 
Namespace(files=['main.py', 'init.py'])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions