Bug 1038459 - zanata-cli <subcommand> should return nonzero if required arguments are missing
Summary: zanata-cli <subcommand> should return nonzero if required arguments are missing
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: zanata-client
Version: 19
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
Assignee: Patrick Huang
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-12-05 07:20 UTC by Ding-Yi Chen
Modified: 2015-01-12 23:58 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-01-12 23:58:18 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1038852 0 unspecified CLOSED Client should be able to read srcdir and transdir from zanata.xml 2021-02-22 00:41:40 UTC

Internal Links: 1038852

Description Ding-Yi Chen 2013-12-05 07:20:37 UTC
Description of problem:
When integrate with other build tool like GNU make, it expected non-zero exit value when error occurred.

Version-Release number of selected component (if applicable):
zanata-client-2.2.0

How reproducible:
Always

Steps to Reproduce:
1. Go to a directory that does not contain zanata.xml (such as /)
2. zanata-cli push
3. echo $?


Actual results:
0

Expected results:
1

Additional info:

Comment 1 Ding-Yi Chen 2013-12-05 07:57:42 UTC
After some further testing, it turns out that by design, "zanata-cli push" produce help for push. It needs -s and -t to make the zanata-cli actually perform push.

So running "zanata-cli push -s . -t." on non zanata directory did return the expected exit code (1).

However, it is not really Linux convention that options are required to actually execute subcommands.

So this bug should really be:
zanata-cli <subcommand> should perform subcommand without any options.

Steps to Reproduce:
1. Go to a directory that does not contain zanata.xml (such as /)
2. zanata-cli push
3. echo $?
4. Go to a directory that does contain zanata.xml and source document
5. zanata-cli push

Actual results:
After Step 2, help for push is shown.
After Step 3, 0 is returned
After Step 5, help for push is shown.

Expected results:
After Step 2, error message "zanata.xml is not found" should be shown.
After Step 3, 1 should be returned.
After Step 5, push should be executed.

Comment 2 Sean Flanigan 2013-12-05 23:29:07 UTC
It's perfectly reasonable for subcommands to have required options, and srcDir/transDir are currently required options.  However:

- I have been thinking that srcDir and transDir should possibly default to "." as in the maven and python clients, in other words cease to be required options

- If the user does omit a required option, we should output the help to stderr (if possible) and return non-zero.

If we do decide on default values for srcDir and transDir, that should be a separate RFE.  In the meantime, we should definitely not return 0 when a required option is missing.

Comment 3 Ding-Yi Chen 2013-12-05 23:47:18 UTC
(In reply to Sean Flanigan from comment #2)
> It's perfectly reasonable for subcommands to have required options, and
> srcDir/transDir are currently required options.  

In that case, put those required options as, well, arguments, i.e. no '-' prefix. 

See 'man cp' as an example of multiple required options.

Refer man pages and behavior of 'git' and 'ip' for the command that requires sub command.

Option should just be optional.

I agreed  the rest of your comment.

> However:
> 
> - I have been thinking that srcDir and transDir should possibly default to
> "." as in the maven and python clients, in other words cease to be required
> options
> 
> - If the user does omit a required option, we should output the help to
> stderr (if possible) and return non-zero.
> 
> If we do decide on default values for srcDir and transDir, that should be a
> separate RFE.  In the meantime, we should definitely not return 0 when a
> required option is missing.

Comment 4 Ding-Yi Chen 2013-12-06 00:00:22 UTC
The default srcDir and destDir is tracked with Bug 1038852.

Comment 5 Sean Flanigan 2013-12-06 00:13:18 UTC
(In reply to Ding-Yi Chen from comment #3)
> (In reply to Sean Flanigan from comment #2)
> > It's perfectly reasonable for subcommands to have required options, and
> > srcDir/transDir are currently required options.  
> 
> In that case, put those required options as, well, arguments, i.e. no '-'
> prefix. 
> 
> See 'man cp' as an example of multiple required options.
> 
> Refer man pages and behavior of 'git' and 'ip' for the command that requires
> sub command.
> 
> Option should just be optional.

Okay, so grammatically speaking, we shouldn't call it an "option" if it's required.

But just because it is announced with a '-' doesn't mean it can't ever be required.  The good thing about using options for this sort of thing is that you can put them in any order, and it's easy to tell which argument is which, because eg, the source directory is always preceded by -s or --src-dir.  (A bit like named method parameters in some programming languages.)

I agree that non-optional options should be used rarely, and it seems to be a bad idea for srcDir/transDir to be required, at least for push.

Comment 6 Fedora End Of Life 2015-01-09 20:47:08 UTC
This message is a notice that Fedora 19 is now at end of life. Fedora 
has stopped maintaining and issuing updates for Fedora 19. It is 
Fedora's policy to close all bug reports from releases that are no 
longer maintained. Approximately 4 (four) weeks from now this bug will
be closed as EOL if it remains open with a Fedora 'version' of '19'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 19 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.


Note You need to log in before you can comment on or make changes to this bug.