Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6631925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:36:53+00:00 2026-05-25T22:36:53+00:00

What is the standard way of storing a command line argument so that it

  • 0

What is the standard way of storing a command line argument so that it can be accessed when required?

I can see 2 scenarios:

  1. The argument is consumed immediately (A logging level)
  2. The argument is not needed immediately (On failure send email to address X)

With scenario 1 It would seem quite natural to configure it upfront, however when it is a scenario more in the vein of scenario 2 I would prefer to configure that component as and when necessary (IE not up front)

So to phrase the question slightly differently how do I make my configuration options available to my entire application?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:36:54+00:00Added an answer on May 25, 2026 at 10:36 pm

    You can use something like that (you can store the CommandLine somewhere or use the opions right away):

    Options options = createOptions();
    CommandLineParser parser = new GnuParser();
    CommandLine cmdLine;
    int timeoutHumanMove;
    try
    {
        cmdLine = parser.parse(options, args, true);
        timeoutHumanMove = getTimeoutOption(cmdLine, "thm", 300);
    }
    catch(ParseException e)
    {
        return;
    }
    
    private static int getTimeoutOption(CommandLine cmdLine, String opt, int defaultSeconds)
        throws ParseException
    {
        if(cmdLine.hasOption(opt))
        {
            Number val = (Number)cmdLine.getParsedOptionValue(opt);
            return (int)(val.doubleValue() * 1000D);
        } else
        {
            return 1000 * defaultSeconds;
        }
    }
    
    private static Options createOptions()
    {
        Options options = new Options();
        options.addOption(OptionBuilder.withDescription("print this help and exit").create(OptionBuilder.withLongOpt("help"), 104));
    
        // ...
        return options;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any standard way of debugging Javascript on a webpage that's being accessed
I have a single string that contains the command-line parameters to be passed to
What's the standard way of storing user preferences in a Flex application for AIR?
Is there a standard way of storing photos on the web, when working with
The standard way to capture command output in Bourne shell is to use the
Here's a barebones Python app that simply prints the command-line arguments passed in: import
Is there a standard way / C# library to convert a string into a
What is the standard way to name an instance: NSString* myString; or NSString* my_string;
Is there a way to zip a string (either with a gem or standard
Is there really no way to print an ascii string in assembly to standard

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.