Giter Site home page Giter Site logo

clipp's People

Contributors

scala-steward avatar vigoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

scala-steward

clipp's Issues

ZIO 2 release

Hi! I see that zio 2 support is on master. Can you make a release please?

dependent parameters

Suppose I want to define an application that takes parameters like this:

app --dir /data --in ./src/input --out ./out/result

where the meaning of -in and -out are file paths that are relative to --dir.

I would like to define the parameters --in and --out dependent on the parameter --dir so that I could have access to the value of the --dir parameter in the custom parsers for --in and --out.

In this example, the custom parser for --in would verify that the relative path, ./src/input, exists in the directory specified by --dir, ie., /data/src/input.

support for scala3

Are there any impediments to cross-building and publishing scala3 binaries?

parsing parameters with multiple values

I would like to define a parameters class like this;

case class Parameters(x: List[String], y: String)

and use clipp to parse the command line arguments like this:

app -x v1 v2 v3 -y foo

or like this:

app -x v1 -x v2 -x v3 -y foo

Filter usage info by known choices

This includes two things:

  • Returning the set of known choices in case of parser error
  • Ability to use this information to show only a part of the usage info (by not using choice for the known values)

Latest ZIO

This is a great library for ZIO - Thank you! Can you bump to the latest ZIO version?

How to define custom parsers for types that have no sensible default value?

The doc for custom parsers requires implementing a type class:

trait ParameterParser[T] {
  def parse(value: String): Either[String, T]
  def default: T
}

For example, using the kebs tag library, I can define a tagged type for an existing executable file like this:

import io.github.vigoo.clipp.ParameterParser
import pl.iterators.kebs.tagged._

  sealed trait ExecutableTag

  implicit val executableFileParser: ParameterParser[Option[File] @@ ExecutableTag] =
    new ParameterParser[Option[File] @@ ExecutableTag] {
      override def parse(value: String): Either[String, Option[File] @@ ExecutableTag] = {
        val f = new File(value)
        val v0 = Right(Some(f).taggedWith[ExecutableTag])
        val v1 = if (f.canExecute) v0 else Left(s"The path must be an executable file, got: $value")
        val v2 = if (f.isFile) v1 else Left(s"The path must be a file, got: $value")
        val v3 = if (f.isAbsolute) v2 else Left(s"The path must be absolute, got: $value")
        v3
      }

      override def default: Option[File] @@ ExecutableTag = None.taggedWith[ExecutableTag]
    }

Since it does not make sense to define a default file value, the custom parameter type is: Option[File] @@ ExecutableTag.

However, when defining a custom parameters data structure, I would like to ensure we have an existing file; however, it is unclear how to turn the lack of a file into a parser error; e.g.:

case class Parameters(tool: File @@ ExecutableTag)

object Parameters {
   val spec: Free[Parameter, Parameters] = for {
     _ <- metadata(....)
     otool <- namedParameter[Option[File] @@ ExecutableTag](
        description = "an executable file",
        placeholder = "tool",
        shortName = 't',
        longNames = "tool")
     tool <- ??? // we would like to get otool if Some and produce an error if otool if None.
   } yield Parameters(tool)
}

How could we solve this problem?

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.