Questions tagged [scopt]

simple scala command line options parsing

29 questions
6
votes
2 answers

NoClassDefFoundError while using scopt OptionParser with Spark

I am using Apache Spark version 1.2.1 and Scala version 2.10.4. I am trying to get the example MovieLensALS working. However, I am running into errors with scopt library which is a requirement in the code. Any help would be appreciated. My…
krishnang
  • 698
  • 1
  • 7
  • 21
5
votes
1 answer

Extending Scopt OptionParser in Scala

I'm trying to have a base option parser with some default parameters. In other projects i would like to extend the option parser with other parameters. Something like: case class Config(foo: String = null) trait DefaultParser { self:…
Udy
  • 2,492
  • 4
  • 23
  • 33
5
votes
1 answer

Scala option parsing with scopt

Using scopt https://github.com/scopt/scopt I have a very simple Scala CLI driver that errors out on the first line of .parse. The line is var i = 0, can’t imagine why that would fail, maybe in how i instantiated the OptionParser? def parse(args:…
pferrel
  • 5,673
  • 5
  • 30
  • 41
3
votes
1 answer

scopt "not found: value" defining val with same name

For the following use of scopt: import java.io.File object Application extends App { case class Config(in: File = new File("."), out: File = new File("."), scripts: Seq[File] = Seq()) val parser = new scopt.OptionParser[Config]("scopt") { …
Jim
  • 1,040
  • 1
  • 10
  • 16
3
votes
2 answers

How can I disable Scopt's "Unknown options" exception?

I have a base Config case class which is used as a common part of the Configs of several different scripts. I'd like to be able to stop copy-pasting code for OptionParsers which parse this base Config (e.g. every single script needs --cluster and…
wrongusername
  • 18,564
  • 40
  • 130
  • 214
2
votes
1 answer

Using the "help" method in the immutable SCOPT (Scala) OptionParser (2.0.1)

I am trying to use the new immutable OptionParser in the Scala scopt 2.0.1 library. Since OptionParser takes a generic type and the help method already defines an action that returns Unit, I am getting a compile-time error: case class…
Ralph
  • 31,584
  • 38
  • 145
  • 282
2
votes
1 answer

Scala scopt: argument required() based on one or more other arguments

I am used to use Scala scopt for command line option parsing. You can choose whether an argument is .required() by calling the just shown function. How can I define an argument that is required only if another argument has been defined? For…
dadadima
  • 938
  • 4
  • 28
2
votes
1 answer

How to parse a case class which has fields as another case class using "scopt" command line argument?

parsing fields(eg-master:String="") works but what if this was inside another case class like case class Job(SparkArgs) given below, and I need to parse JobArgs case class SparkArgs(master: String) val parser = new…
2
votes
2 answers

Scala scopt error with Seq[String]

I'm trying to create a scopt option for Seq[String]: import scopt._ import scopt.Read._ opt[Seq[String]]("foobar") ^ error but the compiler complains that it could not find implicit value for evidence parameter of type…
Ralph
  • 31,584
  • 38
  • 145
  • 282
2
votes
2 answers

Parsing options that take more than one value with scopt in scala

I am using scopt to parse command line arguments in scala. I want it to be able to parse options with more than one value. For instance, the range option, if specified, should take exactly two values. --range 25 45 Coming, from python background, I…
AnkurVj
  • 7,958
  • 10
  • 43
  • 55
1
vote
0 answers

Using Scopt how to validate keys inside a map argument

I am planning to use Scopt to parse my input arguments. My input arguments is a map. I have a require on the map argument which will ensure that map is present. How do i ensure that certain key value pairs are present in the map. object ScalaApp…
BigDataLearner
  • 1,388
  • 4
  • 19
  • 40
1
vote
0 answers

How to package Scala 3 application using the "scopt" library with "Proguard"?

The moment I add a dependency on the scopt library to my Scala 3 application, I am no longer able to successfully package it using Proguard. Upon attempting to run an executable jar, I am only seeing the following error message: Exception in thread…
DJ Gruby
  • 159
  • 1
  • 2
  • 11
1
vote
1 answer

How to do a case insensitive match for command line arguments in scala?

I'm working on a command line tool written in Scala which is executed as: sbt "run --customerAccount 1234567" Now, I wish to make this flexible to accept "--CUSTOMERACCOUNT" or --cUsToMerAccount or --customerACCOUNT ...you get the drift Here's what…
Saturnian
  • 1,686
  • 6
  • 39
  • 65
1
vote
2 answers

case class inheriting another class/trait

I want to have a case class extend a trait Here are my requirements: I need to use a case class for the child. This is a hard requirement because of scopt (https://github.com/scopt/scopt) The parent needs to be a trait. Apologies for not being…
Omkar Neogi
  • 675
  • 2
  • 9
  • 30
1
vote
1 answer

scopt: Is it possible to refactor single Config into smaller Configs?

I have been using scopt with a single case class: case class ArgsConfig( arg1: type1 = value1, arg2: type2 = value2, ... ) I now have a large number of possible arguments which makes the class hard to read. The arguments can be grouped…
user2947133
  • 325
  • 1
  • 3
  • 11
1
2