Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions build.mill
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//| mill-version: 1.0.0
//| mill-version: 1.0.6
//| mill-jvm-version: 11
//| mvnDeps:
//| - com.github.lolgab::mill-mima_mill1:0.2.0

Expand Down Expand Up @@ -30,7 +31,7 @@ trait MainArgsPublishModule

def publishVersion = VcsVersion.vcsState().format()

override def mimaPreviousVersions = Seq("0.6.0")
override def mimaPreviousVersions = Seq("0.7.0", "0.7.1", "0.7.2", "0.7.3", "0.7.4", "0.7.5", "0.7.6")

def mimaReportBinaryIssues() =
if (this.isInstanceOf[ScalaNativeModule] || this.isInstanceOf[ScalaJSModule]) Task.Command{}
Expand Down
2 changes: 1 addition & 1 deletion example/caseclass/src/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ object Main {
bool: Flag = Flag()
)
def main(args: Array[String]): Unit = {
val config = ParserForClass[Config].constructOrExit(args)
val config = Parser[Config].constructOrExit(args)
println(config)
}
}
6 changes: 3 additions & 3 deletions example/classarg/src/Main.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package example.classarg
import mainargs.{main, arg, ParserForMethods, ParserForClass, Flag}
import mainargs.{main, arg, Parser, ParserForClass, Flag}

object Main {
@main
Expand All @@ -11,7 +11,7 @@ object Main {
@arg(doc = "Example flag")
bool: Flag = Flag()
)
implicit def configParser = ParserForClass[Config]
implicit def configParser = Parser[Config]

@main
def bar(
Expand All @@ -26,5 +26,5 @@ object Main {
println((config.foo * config.myNum + " " + config.bool.value + "\n") * n)
}

def main(args: Array[String]): Unit = ParserForMethods(this).runOrExit(args)
def main(args: Array[String]): Unit = Parser(this).runOrExit(args)
}
4 changes: 2 additions & 2 deletions example/custom/src/Main.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package example.custom
import mainargs.{main, arg, ParserForMethods, TokensReader}
import mainargs.{main, arg, Parser, TokensReader}

object Main {
implicit object PathRead extends TokensReader[os.Path](
Expand All @@ -12,5 +12,5 @@ object Main {
println("to: " + to)
}

def main(args: Array[String]): Unit = ParserForMethods(this).runOrExit(args)
def main(args: Array[String]): Unit = Parser(this).runOrExit(args)
}
4 changes: 2 additions & 2 deletions example/hello/src/Main.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package example.hello
import mainargs.{main, arg, ParserForMethods, Flag}
import mainargs.{main, arg, Parser, Flag}

object Main {
@main
Expand All @@ -14,5 +14,5 @@ object Main {
println(foo * myNum + " " + bool.value)
}

def main(args: Array[String]): Unit = ParserForMethods(this).runOrExit(args)
def main(args: Array[String]): Unit = Parser(this).runOrExit(args)
}
4 changes: 2 additions & 2 deletions example/hello2/src/Main.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package example.hello2
import mainargs.{main, arg, ParserForMethods, Flag}
import mainargs.{main, arg, Parser, Flag}

object Main {
@main
Expand All @@ -21,5 +21,5 @@ object Main {
) = {
println(s * i)
}
def main(args: Array[String]): Unit = ParserForMethods(this).runOrExit(args)
def main(args: Array[String]): Unit = Parser(this).runOrExit(args)
}
4 changes: 2 additions & 2 deletions example/optseq/src/Main.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package example.optseq
import mainargs.{main, arg, ParserForMethods, TokensReader}
import mainargs.{main, arg, Parser, TokensReader}

object Main {
@main
Expand All @@ -11,5 +11,5 @@ object Main {
@main
def runVec(seq: Vector[Int]) = println(seq)

def main(args: Array[String]): Unit = ParserForMethods(this).runOrExit(args)
def main(args: Array[String]): Unit = Parser(this).runOrExit(args)
}
4 changes: 2 additions & 2 deletions example/short/src/Main.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package example.hello
import mainargs.{main, arg, ParserForMethods, Flag}
import mainargs.{main, arg, Parser, Flag}

object Main {
@main
Expand All @@ -8,5 +8,5 @@ object Main {
@main
def strs(a: Flag, b: String) = println(Seq(a.value, b))

def main(args: Array[String]): Unit = ParserForMethods(this).runOrExit(args)
def main(args: Array[String]): Unit = Parser(this).runOrExit(args)
}
4 changes: 2 additions & 2 deletions example/vararg/src/Main.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package example.vararg
import mainargs.{main, arg, ParserForMethods, Leftover}
import mainargs.{main, arg, Parser, Leftover}

object Main {
@main
def run(foo: String, myNum: Int = 2, rest: Leftover[String]) = {
println(foo * myNum + " " + rest.value)
}

def main(args: Array[String]): Unit = ParserForMethods(this).runOrExit(args)
def main(args: Array[String]): Unit = Parser(this).runOrExit(args)
}
2 changes: 1 addition & 1 deletion example/vararg2/src/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ object Main {
case class Config(foo: String, myNum: Int = 2, rest: Leftover[String])

def main(args: Array[String]): Unit = {
val config = ParserForClass[Config].constructOrExit(args)
val config = Parser[Config].constructOrExit(args)
println(config)
}
}
4 changes: 2 additions & 2 deletions example/varargold/src/Main.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package example.vararg
import mainargs.{main, arg, ParserForMethods, Leftover}
import mainargs.{main, arg, Parser, Leftover}

object Main {
@main
def run(foo: String, myNum: Int, rest: String*) = {
println(foo * myNum + " " + rest.value)
}

def main(args: Array[String]): Unit = ParserForMethods(this).runOrExit(args)
def main(args: Array[String]): Unit = Parser(this).runOrExit(args)
}
1 change: 1 addition & 0 deletions mainargs/src/Parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import acyclic.skipped
import scala.language.experimental.macros
import java.io.PrintStream

object Parser extends ParserForMethodsCompanionVersionSpecific with ParserForClassCompanionVersionSpecific
object ParserForMethods extends ParserForMethodsCompanionVersionSpecific
class ParserForMethods[B](val mains: MethodMains[B]) {
@deprecated("Binary Compatibility Shim", "mainargs 0.6.0")
Expand Down
8 changes: 4 additions & 4 deletions mainargs/test/src-jvm-2/AmmoniteTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ object AmmoniteConfig {
@arg(doc = "Print this message")
help: Flag
)
implicit val coreParser = ParserForClass[Core]
implicit val coreParser = Parser[Core]

@main
case class Predef(
Expand All @@ -108,7 +108,7 @@ object AmmoniteConfig {
)
noHomePredef: Flag
)
implicit val predefParser = ParserForClass[Predef]
implicit val predefParser = Parser[Predef]

@main
case class Repl(
Expand All @@ -130,11 +130,11 @@ object AmmoniteConfig {
)
classBased: Flag
)
implicit val replParser = ParserForClass[Repl]
implicit val replParser = Parser[Repl]
}

object AmmoniteTests extends TestSuite {
val parser = ParserForClass[AmmoniteConfig]
val parser = Parser[AmmoniteConfig]
val tests = Tests {

test("formatMainMethods.unsorted") {
Expand Down
2 changes: 1 addition & 1 deletion mainargs/test/src-jvm-2/MillTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ object MillTests extends TestSuite {

val tests = Tests {

val parser = ParserForClass[Config]
val parser = Parser[Config]

test("formatMainMethods") {
val rendered = parser.helpText(sorted = false)
Expand Down
16 changes: 8 additions & 8 deletions mainargs/test/src/ClassTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ object ClassTests extends TestSuite {
) = new Compat(home, silent, leftoverArgs)
}

implicit val fooParser: ParserForClass[Foo] = ParserForClass[Foo]
implicit val barParser: ParserForClass[Bar] = ParserForClass[Bar]
implicit val quxParser: ParserForClass[Qux] = ParserForClass[Qux]
implicit val cliParser: ParserForClass[Cli] = ParserForClass[Cli]
implicit val compatParser: ParserForClass[Compat] = ParserForClass[Compat]
implicit val fooParser: ParserForClass[Foo] = Parser[Foo]
implicit val barParser: ParserForClass[Bar] = Parser[Bar]
implicit val quxParser: ParserForClass[Qux] = Parser[Qux]
implicit val cliParser: ParserForClass[Cli] = Parser[Cli]
implicit val compatParser: ParserForClass[Compat] = Parser[Compat]

class PathWrap {
@main
Expand All @@ -60,7 +60,7 @@ object ClassTests extends TestSuite {
}
}

implicit val fooParser: ParserForClass[Foo] = ParserForClass[Foo]
implicit val fooParser: ParserForClass[Foo] = Parser[Foo]
}

object Main {
Expand Down Expand Up @@ -204,7 +204,7 @@ object ClassTests extends TestSuite {
Qux("cow", Bar(Flag(true), Foo(1, 2), "xxx"))
}
test("success") {
ParserForMethods(Main).runOrThrow(
Parser(Main).runOrThrow(
Seq("-x", "1", "-y", "2", "-z", "hello")
) ==> "false 1 2 hello false"
}
Expand All @@ -225,7 +225,7 @@ object ClassTests extends TestSuite {
}
test("path-dependent-default-method") {
val p = new PathWrap
ParserForMethods(p.Main).runOrThrow(
Parser(p.Main).runOrThrow(
Seq("-x", "1", "-y", "2", "-z", "hello")
) ==> "false 1 2 hello false"
}
Expand Down
4 changes: 2 additions & 2 deletions mainargs/test/src/ClassWithDefaultTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ object ClassWithDefaultTests extends TestSuite {
@main
case class Foo(x: Int, y: Int = 1)

implicit val fooParser: ParserForClass[Foo] = ParserForClass[Foo]
implicit val fooParser: ParserForClass[Foo] = Parser[Foo]

object Main {
@main
def run(foo: Foo, bool: Boolean = false) = s"${foo.x} ${foo.y} $bool"
}

val mainParser = ParserForMethods(Main)
val mainParser = Parser(Main)

val tests = Tests {
test("simple") {
Expand Down
2 changes: 1 addition & 1 deletion mainargs/test/src/ConstantTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ object ConstantTests extends TestSuite {
@main
def flaggy(a: Injected, b: Boolean) = a.toString + " " + b
}
val check = new Checker(ParserForMethods(Base), allowPositional = true)
val check = new Checker(Parser(Base), allowPositional = true)

val tests = Tests {
test - check(
Expand Down
2 changes: 1 addition & 1 deletion mainargs/test/src/CoreTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ object CorePositionalDisabledOnlyTests extends TestSuite {
}

object CorePositionalEnabledOnlyTests extends TestSuite {
val check = new Checker(ParserForMethods(CoreBase), allowPositional = true)
val check = new Checker(Parser(CoreBase), allowPositional = true)

val tests = Tests {
test("invoke") {
Expand Down
4 changes: 2 additions & 2 deletions mainargs/test/src/DashedArgumentName.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ object DashedArgumentName extends TestSuite {
@main(name = "camelOptFor29NameForce")
def camelOptFor29NameForce(@arg(name = "camelOptFor29ArgForce") camelOptFor29ArgForce: Boolean) = camelOptFor29ArgForce
}
val check = new Checker(ParserForMethods(Base), allowPositional = true)
val snakeCaseCheck = new Checker(ParserForMethods(Base), allowPositional = true, nameMapper = Util.snakeCaseNameMapper)
val check = new Checker(Parser(Base), allowPositional = true)
val snakeCaseCheck = new Checker(Parser(Base), allowPositional = true, nameMapper = Util.snakeCaseNameMapper)

val tests = Tests {
test("backticked") {
Expand Down
10 changes: 5 additions & 5 deletions mainargs/test/src/EqualsSyntaxTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,27 @@ object EqualsSyntaxTests extends TestSuite {

val tests = Tests {
test("simple") {
ParserForMethods(Main).runOrThrow(Array("--foo=bar", "--my-num=3")) ==>
Parser(Main).runOrThrow(Array("--foo=bar", "--my-num=3")) ==>
"barbarbar false"
}
test("multipleEquals") {
// --foo=bar syntax still works when there's an `=` on the right
ParserForMethods(Main).runOrThrow(Array("--foo=bar=qux")) ==>
Parser(Main).runOrThrow(Array("--foo=bar=qux")) ==>
"bar=quxbar=qux false"
}
test("empty") {
// --foo= syntax sets `foo` to an empty string
ParserForMethods(Main).runOrThrow(Array("--foo=")) ==>
Parser(Main).runOrThrow(Array("--foo=")) ==>
" false"
}
test("shortName") {
// -f=bar syntax does work for short names
ParserForMethods(Main).runEither(Array("-f=bar")) ==>
Parser(Main).runEither(Array("-f=bar")) ==>
Right("barbar false")
}
test("notFlags") {
// -f=bar syntax doesn't work for flags
ParserForMethods(Main).runEither(Array("--foo=bar", "--bool=true")) ==>
Parser(Main).runEither(Array("--foo=bar", "--bool=true")) ==>
Left("""Unknown argument: "--bool=true"
|Expected Signature: run
| --bool Example flag
Expand Down
2 changes: 1 addition & 1 deletion mainargs/test/src/FlagTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ object FlagTests extends TestSuite {
def str(a: Flag, b: String) = Seq(a.value, b)
}

val check = new Checker(ParserForMethods(Base), allowPositional = true)
val check = new Checker(Parser(Base), allowPositional = true)

val tests = Tests {
test - check(
Expand Down
12 changes: 6 additions & 6 deletions mainargs/test/src/HelloWorldTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,27 @@ object HelloWorldTests extends TestSuite {

val tests = Tests {
test("explicit") {
ParserForMethods(Main).runOrThrow(Array("--foo", "bar", "--my-num", "3")) ==>
Parser(Main).runOrThrow(Array("--foo", "bar", "--my-num", "3")) ==>
"barbarbar false"
}
test("short") {
ParserForMethods(Main).runOrThrow(Array("-f", "bar")) ==>
Parser(Main).runOrThrow(Array("-f", "bar")) ==>
"barbar false"
}
test("default") {
ParserForMethods(Main).runOrThrow(Array("--foo", "bar")) ==>
Parser(Main).runOrThrow(Array("--foo", "bar")) ==>
"barbar false"
}
test("positional") {
ParserForMethods(Main).runOrThrow(Array("qux", "4"), allowPositional = true) ==>
Parser(Main).runOrThrow(Array("qux", "4"), allowPositional = true) ==>
"quxquxquxqux false"
}
test("flags") {
ParserForMethods(Main).runOrThrow(Array("qux", "4", "--bool"), allowPositional = true) ==>
Parser(Main).runOrThrow(Array("qux", "4", "--bool"), allowPositional = true) ==>
"quxquxquxqux true"
}
test("either") {
ParserForMethods(Main).runEither(Array("qux", "4", "--bool"), allowPositional = true) ==>
Parser(Main).runEither(Array("qux", "4", "--bool"), allowPositional = true) ==>
Right("quxquxquxqux true")
}
}
Expand Down
2 changes: 1 addition & 1 deletion mainargs/test/src/HygieneTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ object HygieneTests extends TestSuite {
val tests = Tests {
import scala.collection.mutable._
test("importingSeqShouldntFailCompile") {
ParserForMethods(Main)
Parser(Main)
}

}
Expand Down
2 changes: 1 addition & 1 deletion mainargs/test/src/InvocationArgs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ case class LargeArgs(
)

object LargeClassTests extends TestSuite{
val largeArgsParser = ParserForClass[LargeArgs]
val largeArgsParser = Parser[LargeArgs]

val tests = Tests {
test("simple") {
Expand Down
Loading