Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI - Scallop #54

Closed
leobenkel opened this issue Sep 28, 2020 · 2 comments
Closed

CLI - Scallop #54

leobenkel opened this issue Sep 28, 2020 · 2 comments

Comments

@leobenkel
Copy link
Owner

Put Scallop specific code in its own component and make the default version more generic

@DamianReeves
Copy link

I can take a look at this.

@leobenkel
Copy link
Owner Author

leobenkel commented Oct 16, 2020

i would recommend doing those:

  1. create a dummy project using today's set up
  2. test --help
  3. look at the log which described the used commands
  4. access arguments from the application using the snippet of code below (the object Arguments)
  5. test passing a wrong command line
  6. try to access it in to add a spark.option(...)
  7. then, try removing scallop from build.sbt and from
  8. replace what breaks by un-implmented methods in the trait
  9. create a new module with scallop to cut and paste the previous implementation into this isolated module
  10. go back to your dummy project and add the zparkio library as well as the zparkio-scallop library. it should work the same way
  11. copy your dummy project and try to make it work with an other config library.

How to use CommandLine today:

class Arguments(override val args: Seq[String])
    extends ScallopConf(args) with CommandLineArguments.Service {
...
}

object Arguments {
  type ArgumentEnv = CommandLineArguments.CommandLineArguments[Arguments]

  def apply(): ZIO[ArgumentEnv, Throwable, Arguments] =
    CommandLineArguments.apply[Arguments]()

  def apply[A](f: Arguments => A): ZIO[ArgumentEnv, Throwable, A] =
    CommandLineArguments.get[Arguments].map(_.apply(f))
}

which allow to do :

for {
   path <- Arguments(_.readPath)
   ds <- readUserFrom(path)
} yield ds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants