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 8774857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:40:22+00:00 2026-06-13T18:40:22+00:00

I’m fairly new to Scala and need to build a really simple command line

  • 0

I’m fairly new to Scala and need to build a really simple command line parser which provides something like the following which I created using JRuby in a few minutes:-

java -jar demo.jar --help

Command Line Example Application

Example: java -jar demo.jar --dn "CN=Test" --nde-url "http://www.example.com" --password "password"

For usage see below:

    -n http://www.example.com
    -p, --password             set the password
    -c, --capi                 set add to Windows key-store
    -h, --help                 Show this message
    -v, --version              Print version

Scallop looks like it will do the trick, but I can’t seem to find a simple example that works! All of the examples I’ve found seem to be fragmented and don’t work for some reason or other.

UPDATE

I found this example which works, but I’m not sure how to bind it into the actual args within the main method.

import org.rogach.scallop._; 

object cmdlinetest {
  def main(args: Array[String]) 

    val opts = Scallop(List("-d","--num-limbs","1"))
      .version("test 1.2.3 (c) 2012 Mr Placeholder")
      .banner("""Usage: test [OPTION]... [pet-name]
                |test is an awesome program, which does something funny
                |Options:
                |""".stripMargin)
      .footer("\nFor all other tricks, consult the documentation!")
      .opt[Boolean]("donkey", descr = "use donkey mode")
      .opt("monkeys", default = Some(2), short = 'm')
      .opt[Int]("num-limbs", 'k',
      "number of libms", required = true)
      .opt[List[Double]]("params")
      .opt[String]("debug", hidden = true)
      .props[String]('D',"some key-value pairs")
      // you can add parameters a bit later
      .args(List("-Dalpha=1","-D","betta=2","gamma=3", "Pigeon"))
      .trailArg[String]("pet name")
      .verify

    println(opts.help)
  }
}
  • 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-06-13T18:40:22+00:00Added an answer on June 13, 2026 at 6:40 pm

    Well, I’ll try to add more examples 🙂

    In this case, it would be much better to use ScallopConf:

    import org.rogach.scallop._
    
    object Main extends App {
      val opts = new ScallopConf(args) {
        banner("""
    NDE/SCEP Certificate enrollment prototype
    
    Example: java -jar demo.jar --dn CN=Test --nde-url http://www.example.com --password password
    
    For usage see below:
        """)
    
        val ndeUrl = opt[String]("nde-url")
        val password = opt[String]("password", descr = "set the password")
        val capi = toggle("capi", prefix = "no-", descrYes = "enable adding to Windows key-store", descrNo = "disable adding to Windows key-store")
        val version = opt[Boolean]("version", noshort = true, descr = "Print version")
        val help = opt[Boolean]("help", noshort = true, descr = "Show this message")
    
      }
    
      println(opts.password())
    }
    

    It prints:

    $ java -jar demo.jar --help
    
    NDE/SCEP Certificate enrollment prototype
    
    Example: java -jar demo.jar --dn CN=Test --nde-url http://www.example.com --password password
    
    For usage see below:
    
      -c, --capi              enable adding to Windows key-store 
          --no-capi           disable adding to Windows key-store 
          --help              Show this message 
      -n, --nde-url  <arg>     
      -p, --password  <arg>   set the password 
          --version           Print version 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters

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.