Giter VIP home page Giter VIP logo

commander-scala's People

Contributors

acrisci avatar tashoyan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

tashoyan mslinn

commander-scala's Issues

Recommendation for unnamed arguments

If a program has several unnamed arguments, how would you suggest parsing them? For example, the case class below stores 5 options and 4 unnamed parameters (with defaults) that configure a program. If values for the 4 unnamed parameters are supplied they should be used, in the order supplied. Otherwise, default values should be used.

Looking at the source code, it seems that the values not associated with any option are passed along as program.args. Is that the best way to access those values for this purpose? Some of those values might need to be converted to Ints, Longs, etc, so it would be nice to use the mechanism already in commander-scala for doing that.

import com.github.acrisci.commander.Program
import java.io.File

abstract sealed case class Options(
  consumerKey: String,
  consumerSecret: String,
  accessToken: String,
  accessTokenSecret: String,
  overWrite: Boolean = false,
  tweetDirectory: File = new File("~/twitterClassifier/tweets/"),
  numTweetsToCollect: Int = 100,
  intervalSecs: Int = 1,
  partitionsEachInterval: Int = 1
)

object Options {
  def apply(args: Array[String]): Options = {
    val program = new Program()
      .version("2.0.0")
      .option(flags="-c, --consumerKey [type]",       description="Twitter OAuth Consumer Key",        required=true)
      .option(flags="-s, --consumerSecret [type]",    description="Twitter OAuth Consumer Secret",     required=true)
      .option(flags="-t, --accessToken [type]",       description="Twitter OAuth Access Token",        required=true)
      .option(flags="-v, --accessTokenSecret [type]", description="Twitter OAuth Access Token Secret", required=true)
      .option(flags="-x, --overWrite",                description="Overwrite data files on each run [false]", default=false)
      .parse(args)

    if (args.isEmpty) program.help

    new Options(
      consumerKey = program.consumerKey,
      consumerSecret = program.consumerSecret,
      accessToken = program.accessToken,
      accessTokenSecret = program.accessTokenSecret,
      overWrite = program.overWrite
     // mandatory unnamed parameters would go here
    ){}
  }
}

Error running the parser method on scala 2.11

Error running the parser method on scala 2.11

I am using the package: "com.github.acrisci" % "commander_2.11" % "0.1.0" withSources()

Exception in thread "main" java.lang.NoSuchMethodError: scala.runtime.ObjectRef.create(Ljava/lang/Object;)Lscala/runtime/ObjectRef;
at com.github.acrisci.commander.Program.normalize(Program.scala:314)
at com.github.acrisci.commander.Program.parse(Program.scala:225)
at com.databricks.apps.twitterClassifier.CollectOptions$.parse(CollectOptions.scala:21)
at com.databricks.apps.twitterClassifier.Collect$.delayedEndpoint$com$databricks$apps$twitterClassifier$Collect$1(Collect.scala:11)
at com.databricks.apps.twitterClassifier.Collect$delayedInit$body.apply(Collect.scala:10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.