File tree Expand file tree Collapse file tree 4 files changed +20
-14
lines changed
cli-options/src/main/scala/scala/cli/commands/pgp
cli/src/main/scala/scala/cli/commands/pgp
options/src/main/scala-3.1/scala/build/options Expand file tree Collapse file tree 4 files changed +20
-14
lines changed Original file line number Diff line number Diff line change
1
+ package scala .cli .commands .pgp
2
+
3
+ import caseapp ._
4
+
5
+ final case class DummyOptions ()
6
+
7
+ object DummyOptions {
8
+ implicit lazy val parser : Parser [DummyOptions ] = Parser .derive
9
+ implicit lazy val help : Help [DummyOptions ] = Help .derive
10
+ }
File renamed without changes.
Original file line number Diff line number Diff line change @@ -4,13 +4,13 @@ import caseapp._
4
4
5
5
import scala .cli .commands .util .CommandHelpers
6
6
7
- abstract class ExternalCommand extends Command [ExternalCommand . DummyOptions ] with CommandHelpers {
7
+ abstract class ExternalCommand extends Command [DummyOptions ] with CommandHelpers {
8
8
override def hasHelp = false
9
9
override def stopAtFirstUnrecognized = true
10
10
11
11
def actualHelp : Help [_]
12
12
13
- def run (options : ExternalCommand . DummyOptions , args : RemainingArgs ): Unit = {
13
+ def run (options : DummyOptions , args : RemainingArgs ): Unit = {
14
14
val unparsedPart =
15
15
if (args.unparsed.isEmpty) Nil
16
16
else Seq (" --" ) ++ args.unparsed
@@ -20,14 +20,3 @@ abstract class ExternalCommand extends Command[ExternalCommand.DummyOptions] wit
20
20
21
21
def run (args : Seq [String ]): Unit
22
22
}
23
-
24
- object ExternalCommand {
25
-
26
- final case class DummyOptions ()
27
-
28
- object DummyOptions {
29
- implicit lazy val parser : Parser [DummyOptions ] = Parser .derive
30
- implicit lazy val help : Help [DummyOptions ] = Help .derive
31
- }
32
-
33
- }
Original file line number Diff line number Diff line change 1
1
package scala .build .options
2
2
3
- import scala .deriving .*
4
3
import scala .compiletime .*
4
+ import scala .deriving .*
5
+
5
6
trait ConfigMonoid [T ]:
6
7
def zero : T
7
8
def orElse (main : T , defaults : T ): T
8
9
10
+ def sum (values : Seq [T ]): T =
11
+ values.foldLeft(zero)(orElse(_, _))
12
+
9
13
case class ConfigMonoidImpl [T ](override val zero : T )(orElseFun : (T , T ) => T )
10
14
extends ConfigMonoid [T ]:
11
15
def orElse (main : T , defaults : T ) = orElseFun(main, defaults)
@@ -19,6 +23,9 @@ object ConfigMonoid:
19
23
def orElse (main : T , defaults : T ) = orElseFn(main, defaults)
20
24
}
21
25
26
+ def sum [T ](values : Seq [T ])(implicit monoid : ConfigMonoid [T ]): T =
27
+ monoid.sum(values)
28
+
22
29
given seq [T ]: ConfigMonoid [Seq [T ]] = ConfigMonoidImpl (Nil )(_ ++ _)
23
30
given list [T ]: ConfigMonoid [List [T ]] = ConfigMonoidImpl (Nil )(_ ++ _)
24
31
given set [T ]: ConfigMonoid [Set [T ]] = ConfigMonoidImpl (Set .empty)(_ ++ _)
You can’t perform that action at this time.
0 commit comments