Skip to content

Commit

Permalink
Swap over script @main and Ammonite main argument parsing over to htt…
Browse files Browse the repository at this point in the history
…ps://github.com/lihaoyi/mainargs (#1126)

This brings with it slight incompatibilities that arise from the cleaned up API, but lets us delete large swathes of boilerplate code that are copy-pasted between this and other repositories I maintain
  • Loading branch information
lihaoyi authored Nov 22, 2020
1 parent 4bd225e commit 0833981
Show file tree
Hide file tree
Showing 21 changed files with 239 additions and 1,224 deletions.
15 changes: 13 additions & 2 deletions amm/interp/src/main/scala/ammonite/interp/AmmonitePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -316,15 +316,26 @@ object LineNumberModifier {
// relaxing the aggressive validation.
val newPos = tree.pos match {
case s : TransparentPosition if s.start > topWrapperLen =>
new TransparentPosition(trimmedSource, s.start, s.point - topWrapperLen, s.end)
new TransparentPosition(
trimmedSource,
s.start - topWrapperLen,
s.point - topWrapperLen,
s.end - topWrapperLen
)
case s: RangePosition if s.start > topWrapperLen =>
new RangePosition(trimmedSource, s.start, s.point - topWrapperLen, s.end)
new RangePosition(
trimmedSource,
s.start - topWrapperLen,
s.point - topWrapperLen,
s.end - topWrapperLen
)
case s: OffsetPosition if s.start > topWrapperLen =>
new OffsetPosition(trimmedSource, s.point - topWrapperLen)
case s => s

}
transformedTree.pos = newPos

transformedTree
}

Expand Down
4 changes: 2 additions & 2 deletions amm/interp/src/main/scala/ammonite/interp/Interpreter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -716,8 +716,8 @@ object Interpreter{
ImportData("ammonite.runtime.tools.{browse, grep, time}"),
ImportData("ammonite.runtime.tools.tail", importType = ImportData.TermType),
ImportData("ammonite.repl.tools.{desugar, source}"),
ImportData("ammonite.main.Router.{doc, main}"),
ImportData("ammonite.repl.tools.Util.pathScoptRead")
ImportData("mainargs.{arg, main}"),
ImportData("ammonite.repl.tools.Util.PathRead")
)


Expand Down
Loading

0 comments on commit 0833981

Please sign in to comment.