TylerTemp / docpie

An easy and Pythonic way to create your POSIX command line
MIT License
22 stars 1 forks source link

Improvement proposals #7

Open pborglin opened 6 years ago

pborglin commented 6 years ago

Hey! Thanks for a really good package. We are now using it for one of our internal tools. This is not a bug report, but some proposals for improvements, that we think would make the package even better.

  1. Add an api option to only allow exact matching of options. Right now we have an option --compress_lzss. If you type --compress at the command line, it will be interpreted as --compress_lzss, since no other option starts with --compress. But later on we will also add an option --compress_proprietary. If you then have created scripts to run the CLI, containing --compress, then will then stop to work. So therefore we would like to only accept options if they are completely right entered.

  2. Give a message "Unknown Command" when an unknown command is entered (Just as for unknown options)

    Usage: pie.py get --opt1=O1 --opt2=O2

    But when I give argv as:

    gett --opt1 ds --opt2 ds

    it give the result:

    
    Usage: pie.py get --opt1=O1 --opt2=O2

Usage: pie.py get --opt1=O1 --opt2=O2

And when I give argv as: 

get --optt1 ds --opt2 ds

it give the result:

Unknown option: --optt1.

Usage: pie.py get --opt1=O1 --opt2=O2

  1. Give an error message if two or more "this|or|that" parameters are entered at the same time Now it is only showing "usage: "
    Usage: pie.py create (--opt1=O1 | --opt2=O2)

    But when I give argv as:

    create --opt1 1 --opt2 2

    it give the result:

    Usage: pie.py create (--opt1=O1 | --opt2=O2)

    Please respond if you think this is something to add or not.

Best Regards, Pernilla

docpie version: 0.3.6 / Sat Jul 1 01:54:16 2017

TylerTemp commented 6 years ago

The first one is, indeed, a change I want to implement.

The second one, actually, I've considered it since I started this project. However, it's not that easy as it seems. I gave up on this feature because: when a non-exists argv value appears, and there are multi use-cases, it's difficult to determine it's a non-exists command or a missed args

The third one is due to the implement. When writing

Usage: prog (-a | -b | -c)

It will internally be expanded to

Usage: 
    prog -a
    prog -b
    prog -c

Which will lead docpie miss the "exclusive" information. And the following usage works in docpie:

Usage: 
    prog (-a | -b | -c)
    prog -a -b
    prog -a -c
    prog -b -c

But, is it acceptable? Should this give an error? :(

So, in short:

  1. Long option auto-expanding should be disabled or provide a way to disable
  2. Better help message for unknown command: good one. As it may give incorrect help message in some situations, I first need to consider it carefully about how to implement it
  3. Exclusive may require changing the code flow. This should think twice and may come much much later if it makes sense (or never... =__=, or I/you/anyone can come up with a better solution)

Priority order: 1 > 2/3

Thanks for opening this issue. Due to my job, I may have little time working on these (but I'll try). Pull requests are welcome :)

pborglin commented 6 years ago

Hi, Thanks for your quick response! I see your point in number two. And for number three I understand that it is good to be able to enter two options of three. For the third point we will probably add our own checks in the code.

Best Regards, Pernilla

From: Tyler Temp [mailto:notifications@github.com] Sent: den 26 oktober 2017 18:00 To: TylerTemp/docpie docpie@noreply.github.com Cc: Borglin, Pernilla pernilla.borglin@volvocars.com; Author author@noreply.github.com Subject: Re: [TylerTemp/docpie] Improvement proposals (#7)

The first one is, indeed, a change I want to implement.

The second one, actually, I've considered it since I started this project. However, it's not that easy as it seems. I gave up on this feature because: when a non-exists argv value appears, and there are multi use-cases, it's difficult to determine it's a non-exists command or a missed args

The third one is due to the implement. When writing

Usage: prog (-a | -b | -c)

It will internally be expanded to

Usage:

prog -a

prog -b

prog -c

Which will lead docpie miss the "exclusive" information. And the following usage works in docpie:

Usage:

prog (-a | -b | -c)

prog -a -b

prog -a -c

prog -b -c

But, is it acceptable? Should this give an error? :(

So, in short:

  1. Long option auto-expanding should be disabled or provide a way to disable
  2. Better help message for unknown command: good one. As it may give incorrect help message in some situations, I first need to consider it carefully about how to implement it
  3. Exclusive may require changing the code flow. This should think twice and may come much much later if it makes sense (or never... =__=, or I/you/anyone can come up with a better solution)

Priority order: 1 > 2/3

Thanks for opening this issue. Due to my job, I may have little time working on these (but I'll try). Pull requests are welcome :)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/TylerTemp/docpie/issues/7#issuecomment-339714383, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AcCcHRQn5Lmdhri0fM3melQjE28Thdxlks5swKyFgaJpZM4QET0N.