All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.halcony.argparse.parsing.HelpFlag.scala Maven / Gradle / Ivy

Go to download

A re-imagined implementation of the handy python-argparse functionality for scala

There is a newer version: 2.0.3
Show newest version
package de.halcony.argparse.parsing

import de.halcony.argparse.ParsingResult

object HelpException extends Throwable

object HelpFlag
    extends FlagArgument("help", 'h', "help", "show this help dialog") {

  override def parse(args: Iterable[String])(
      implicit result: ParsingResult): Iterable[String] = {
    if (args.nonEmpty && (args.head == this.short || args.head == this.long)) {
      throw HelpException
    } else {
      result.addResult("help", new ResultValue[Boolean](false))
      args
    }
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy