Bug 196052 - Ability to exit app when wrong CLI options passed in
Ability to exit app when wrong CLI options passed in
Status: RESOLVED FIXED
Product: platform
Classification: Unclassified
Component: Launchers&CLI
7.0
Other Linux
: P1 (vote)
: 7.1
Assigned To: Jaroslav Tulach
issues@platform
: API_REVIEW_FAST
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-02-27 07:56 UTC by Jaroslav Tulach
Modified: 2011-05-15 08:37 UTC (History)
3 users (show)

See Also:
Issue Type: ENHANCEMENT
:


Attachments
Implementation and API documentation (9.22 KB, patch)
2011-02-27 08:32 UTC, Jaroslav Tulach
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jaroslav Tulach 2011-02-27 07:56:18 UTC
The NetBeans IDE continues to start when wrong CLI options are passed in. This is OK, as the only option --open is not essential. However for certain applications on NetBeans it does not make sense to start when options are not provided.

So far one can call LifecycleManager.exit() from the OptionProcessor. However calling this API from middle of startup sequence cannot really bulletproof. I've seen it to leave the layout of windowsystem in very bad shape.

Having nicer API to achieve the same would be desirable.
Comment 1 Jaroslav Tulach 2011-02-27 08:32:48 UTC
Created attachment 106488 [details]
Implementation and API documentation
Comment 2 Jaroslav Tulach 2011-02-27 08:34:33 UTC
I'd like to get this change into 7.0. That means to integrate by Tuesday. Can I find few reviewers that could approve/verify the change and let me integrate without a week of waiting time?
Comment 3 Jesse Glick 2011-03-03 00:29:20 UTC
"...when some CLI cannot..." - missing "option" I guess.


[JG01] This change seems very magical and relies on an atypical use of a special bundle key. Why does it need to be so complicated? Just define a constant in CommandException:

  public static final int FORCE_EXIT = -1; // or whatever

If some processor throws a CE with this exit code, terminate the app rather than just issuing a warning.

(I find it surprising that the exit code param to CE does not already terminate the app; its Javadoc does say "the value to be usually send to as a return value to System.exit".)
Comment 4 Jaroslav Tulach 2011-03-03 21:16:43 UTC
> relies on an atypical use of a special bundle key

C'mon. Using bundles to differentiate the behavior between different applications build on top of Netbeans Platform is normal. Window system does that. If the behavior of the IDE and other applications shall be different, Bundle is a perfect way to specify that.
 
> (I find it surprising that the exit code param to CE does not already terminate
> the app; its Javadoc does say "the value to be usually send to as a return
> value to System.exit".)

Right, the error code shall terminate the app I can change the default in the platform. Shall the NetBeans IDE exit if someone passes non-existent file to --open too?

> . Why does it need to be so complicated? Just define a
> constant in CommandException: public static final int FORCE_EXIT = -1; 

OK, this would be compatible extension with a bunch of freedom for OptionProcessor writers. If none of the above approaches is acceptable, then I can implement this one.
Comment 5 Jesse Glick 2011-03-03 21:40:36 UTC
(In reply to comment #4)
> this would be compatible extension with a bunch of freedom for
> OptionProcessor writers.

And much more discoverable than the current proposal, which forces you to go looking for a magic bundle value hidden in an arch document which is not even in the public API set.
Comment 6 Jaroslav Tulach 2011-03-04 14:32:20 UTC
I guess I try something else: I exit the system whenever a processor yields non-zero value. I keep the branding API for those who want to keep current behavior.
Comment 7 Jesse Glick 2011-03-04 15:49:03 UTC
(In reply to comment #6)
> I exit the system whenever a processor yields non-zero value.

Seems reasonable default behavior, seeing as this is what the documentation already implies. After all, if there is some problem but you _don't_ want your processor to exit, you can simply print a warning message but return 0; is there any other reason to return a nonzero value? (To stop parsing of subsequent args perhaps?)
Comment 8 Jaroslav Tulach 2011-05-11 13:12:49 UTC
OK, I change the code to exit the application if non-zero code is returned.
Comment 9 Jaroslav Tulach 2011-05-13 17:49:02 UTC
ergonomics#df53730d2efa
Comment 10 Quality Engineering 2011-05-15 08:37:44 UTC
Integrated into 'main-golden', will be available in build *201105150400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/df53730d2efa
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #196052: Exit when command line options cannot be parsed


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo