Skip to content

Commit

Permalink
Fix short for flag not being applied (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
keynmol authored Aug 6, 2024
1 parent 98ac852 commit 6b7b583
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
8 changes: 5 additions & 3 deletions library.test.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,12 @@ class Tests extends FunSuite:
assertArgs[Cmd](Cmd(Some("shroom"), true))("--yepp", "shroom", "--flag2")

test("argument hints: short"):
case class Cmd(@arg(_.Short("y")) location: Option[String])
derives CommandApplication
case class Cmd(
@arg(_.Short("y")) location: Option[String],
@arg(_.Short("X")) flag: Boolean
) derives CommandApplication

assertArgs[Cmd](Cmd(Some("shroom")))("-y", "shroom")
assertArgs[Cmd](Cmd(Some("shroom"), true))("-y", "shroom", "-X")

test("argument hints: flag default"):
case class Cmd(@arg(_.FlagDefault(true)) isLit: Boolean)
Expand Down
10 changes: 6 additions & 4 deletions macros.scala
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,17 @@ private[decline_derive] object Macros:
case None =>
Opts
.flag(
${ hints.name }.getOrElse($nm),
${ hints.help }.getOrElse("")
long = ${ hints.name }.getOrElse($nm),
help = ${ hints.help }.getOrElse(""),
short = ${ hints.short }.getOrElse("")
)
.orFalse
case Some(value) =>
Opts
.flag(
${ hints.name }.getOrElse($nm),
${ hints.help }.getOrElse("")
long = ${ hints.name }.getOrElse($nm),
help = ${ hints.help }.getOrElse(""),
short = ${ hints.short }.getOrElse("")
)
.orTrue
}
Expand Down

0 comments on commit 6b7b583

Please sign in to comment.