Questions tagged [scopt]

simple scala command line options parsing

29 questions
1
vote
1 answer

Declare required sub-commands with scopt

I want to declare required sub-commands using scopt (or sth. similar but Scala based). For example, I want to have the following synopsis (similar to man git, for example): mycli [--version] [--help] [] whereas is required…
nemron
  • 701
  • 6
  • 23
0
votes
1 answer

How to run scopt scala apllication

I am using this library to write cli application: https://github.com/scopt/scopt I can run my application only inside sbt with command: run --foo 2 -b 1 Ideally I would like to run my application in terminal like this: myapp --foo 2 -b 1 or this…
0
votes
0 answers

Scopt for complex types

import scopt.Read.stringRead._ case class Config( kwargs: Map[String, Map[String, List[String]]] = Map() ) val parser: OptionParser[Config] = new scopt.OptionParser[Config]("test") { head("Test Server", "v1") opt[Map[String,…
Avenger
  • 793
  • 11
  • 31
0
votes
1 answer

How to write test with checking incorrect string pattern for parsing

I want to write test code which check parsing of the string of numbers with comma delimiter. The code is: case class TestConfig(macroregions: Option[Seq[Int]] = None) object TestConfig { private val parser = new…
Vadim
  • 753
  • 8
  • 22
0
votes
1 answer

How can I use scopt in Scala to get all of the remaining arguments?

I'm using the scopt library: https://github.com/scopt/scopt I see that I can define a case class with option names if I know them beforehand. What if I don't know the names of the options that the user will pass? Is there any way for me to capture…
Neel
  • 597
  • 6
  • 19
0
votes
0 answers

spark submit-read command line argument which is config file [HOCON] using Scopt and ConfigFactory

I have a jar that I am running through spark-submit and earlier i was using Argot to parse a HOCON config file which was parsed through ConfigFactory and then I'd read from there. * spark/bin/spark-submit --class ConsumerApp \ * …
Egyptian
  • 63
  • 1
  • 3
  • 9
0
votes
0 answers

Type List takes type parameters

I have the following data: val param1 = List(("f1","f2","f3"), ("d1","d2","d2")) The number of rows in this List is not fixed. I want to pass these data as the input parameter of my Scala object. import scopt.OptionParser object…
Markus
  • 3,562
  • 12
  • 48
  • 85
0
votes
1 answer

How to pattern match on Scala Scopt optional arguments

I have a simple Scops parser that looks like val parser: scopt.OptionParser[Config] = new scopt.OptionParser[Config]("my-app") { head("scopt", "3.x") (...) opt[String]('q', "query") .text("The query.") .action { (value, conf) =>…
Vassilis Moustakas
  • 573
  • 1
  • 7
  • 17
0
votes
1 answer

How can I accept an unlabeled argument in scopt?

I'm using scopt to process command line arguments and would like to accept a blind/unlabeled argument. Let's take a super-simplified, familiar 'ls' command as an example: ls [] [options] where options is just one: --tree So examples of…
Greg
  • 10,696
  • 22
  • 68
  • 98
0
votes
1 answer

running sbt class using only a jar

Is there any way to run sbt commands with only a jar instead of a project? I've been having issues using scopt with java or scala commands, and it only seems to work with sbt. Ideally something like sbt --jar /"run-main
Daniel Imberman
  • 618
  • 1
  • 5
  • 18
0
votes
1 answer

scopt3 sample script does not compile

I'm trying to use scopt3 in my project but I get compilation errors even for the sample code on scopt3 Github page: val parser = new scopt.OptionParser[Config]("scopt") { head("scopt", "3.x") opt[Int]('f', "foo") action { (x, c) => …
Max
  • 2,508
  • 3
  • 26
  • 44
0
votes
1 answer

Running a scopt option with no values

I am writing a CLI in Scala using Scopt. I would like to add in the ability to call a command with or without the values. For example: CliUtility -o Would send in a Seq[String] of the values. I want to also be able to run…
micoris
  • 3
  • 3
0
votes
1 answer

Combining CommandLine Option Parsers with Scopt

I am currently using scopt for a Command Line Application. However My scopt.OptionParser[Config] is getting very large. I was thinking it might be nice to break it into smaller parts, and then combine them. After reading the documentation I don't…
Nicholas Marshall
  • 2,981
  • 2
  • 26
  • 22
0
votes
1 answer

Scala scopt code - map getorelse?

i am new to scala and do not understand what this code is doing: parser.parse(args, Config()) map { config => //do stuff here } getOrElse { //handle stuff here } This is from the scopt library found here Ideally what i want to do is put my…
bharal
  • 15,461
  • 36
  • 117
  • 195
1
2