File tree Expand file tree Collapse file tree 4 files changed +47
-24
lines changed
Expand file tree Collapse file tree 4 files changed +47
-24
lines changed Original file line number Diff line number Diff line change 11# scala-argparse
22
3+ [ ![ project docs] ( https://img.shields.io/badge/docs-website-blueviolet )] ( https://jodersky.github.io/scala-argparse )
4+ [ ![ project chat] ( https://img.shields.io/badge/zulip-join_chat-brightgreen.svg )] ( https://crashbox.zulipchat.com/#narrow/stream/330744-argparse )
35[ ![ Latest version] [ scaladex-badge ]] [ scaladex-link ]
46
5- [ scaladex-badge ] : https://index.scala-lang.org/jodersky/scala-argparse/argparse/latest-by-scala-version .svg
7+ [ scaladex-badge ] : https://index.scala-lang.org/jodersky/scala-argparse/argparse/latest.svg
68[ scaladex-link ] : https://index.scala-lang.org/jodersky/scala-argparse/argparse
79
810Pragmatic command line parsing for Scala applications.
Original file line number Diff line number Diff line change 11
22class Foo
33
4- // object api extends argparse.core.Api {
4+ object api extends argparse.core.Api {
55
6- // given Reader[Foo] with {
7- // def read(a: String): Reader.Result[Foo] = Reader.Success(Foo())
8- // def typeName: String = ""
9- // }
6+ given Reader [Foo ] with {
7+ def read (a : String ): Reader .Result [Foo ] = Reader .Success (Foo ())
8+ def typeName : String = " "
9+ }
1010
11- // }
11+ }
1212
1313
1414
15- class yo (base : Int ) {
15+ class wrapper (base : Int ) {
1616
1717 @ argparse.main()
18- def foo (value : Int = base * 3 , paths : List [os. Path ] = Nil ) = {
18+ def command1 (value : Int = base * 3 , unsupported : Foo ) = {
1919 println(value)
20- println(paths)
2120 }
2221
23- // @argparse.main()
24- // def bar () = {
22+ @ argparse.main()
23+ def command2 () = {
2524
26- // }
25+ }
2726
28- // @argparse.main()
29- // def baz (q: Int) = {
30- // println(base * q)
31- // }
27+ @ argparse.main()
28+ def command3 (q : Int ) = {
29+ println(base * q)
30+ }
3231
3332}
3433
3534@ argparse.main()
36- def foo (value : Int = 3 , paths : List [os. Path ] = Nil ) = {
37- println(value )
38- println(paths )
35+ def foo (base : Int = 1 ) = {
36+ println(base )
37+ // wrapper(base )
3938}
4039
41- // val x = this
42-
4340// this should become obsolete once macro annotations are available
44- def main (args : Array [String ]) = argparse.default.main(this , args)
41+ // def main(args: Array[String]) = api.main(this, args)
42+
43+ def main (args : Array [String ]) = {
44+ val parser = argparse.default.ArgumentParser ()
45+
46+ val base = parser.param[Int ](
47+ " --base" ,
48+ default = 1
49+ )
50+
51+ parser.parseOrExit(args)
52+ foo(base.value)
53+
54+ }
4555
4656// val entrypoints = argparse.default.initialize[yo]
4757
Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ Pragmatic command line parsing for Scala applications.
1515
1616- Works with Scala 2 and 3, Native and JVM
1717
18+ - Support for subcommands (aka "verbs")
19+
1820## Example
1921
2022``` scala
Original file line number Diff line number Diff line change 8989 </ button >
9090 < div class ="collapse navbar-collapse " id ="navbarNav ">
9191 < ul class ="navbar-nav me-auto ">
92-
92+ < li class ="nav-item ">
93+ < a href ="https://index.scala-lang.org/jodersky/scala-argparse/argparse ">
94+ < img alt ="latest version " src ="https://index.scala-lang.org/jodersky/scala-argparse/argparse/latest.svg ">
95+ </ a >
96+ </ li >
97+ < li class ="nav-item ">
98+ < a href ="https://crashbox.zulipchat.com/#narrow/stream/330744-argparse ">
99+ < img alt ="project chat " src ="https://img.shields.io/badge/zulip-join_chat-brightgreen.svg ">
100+ </ a >
101+ </ li >
93102 </ ul >
94103 <!-- <form class="d-flex me-auto" role="search">
95104 <input class="form-control-sm" type="search" placeholder="Search" aria-label="Search">
You can’t perform that action at this time.
0 commit comments