Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inspect should render a parameter usage help for commands #2198

Closed
lefou opened this issue Dec 15, 2022 · 1 comment · Fixed by #2522
Closed

inspect should render a parameter usage help for commands #2198

lefou opened this issue Dec 15, 2022 · 1 comment · Fixed by #2522
Milestone

Comments

@lefou
Copy link
Member

lefou commented Dec 15, 2022

The inspect command already prints the scaladoc. Whan commands have parameters documented with @param, we already see them too, but often parameters are not documented. Also, if we use dedicated classes that used the delegation support on mainargs, we don't see the documentation.

As Mill is automatically supporting parameters with mainargs and mainargs can render nice usage displays, we should include such usage output to the output of inspect.

@lefou lefou changed the title inspect should render a paraemetr usage help for commands inspect should render a parameter usage help for commands Dec 15, 2022
@lefou
Copy link
Member Author

lefou commented Jan 24, 2023

lihaoyi added a commit that referenced this issue May 16, 2023
Fixes #2198

There's a bit of duplication if a user both adds `@mainargs.arg(doc =
"...")` scala annotation as well as a `@param foo` scaladoc annotation,
but that's an inherent issue with mainargs and not something we aim to
fix here.

We render the mainargs CLI help message the same way it's done in
mainargs. There isn't a nice helper that renders the whole thing at
once, so i have to piece it together from various helpers, but it's not
too complex and works out ok.

Tested via additions to
`integration.feature[docannotations].local.test`, and manually

```bash
$ ./mill -i dev.run example/basic/1-simple-scala -i inspect run # command with 1 arg
run(JavaModule.scala:720)
    Runs this modules code in a subprocess and waits for it to finish

    args <str>...

Inputs:
    finalMainClass
    runClasspath
    forkArgs
    forkEnv
    forkWorkingDir
    runUseArgsFile

$ ./mill -i dev.run example/basic/1-simple-scala -i inspect compile # not a command
compile(ScalaModule.scala:211)
    Compiles the current module to generate compiled classfiles/bytecode.

    When you override this, you probably also want to override [[bspCompileClassesPath]].

Inputs:
    scalaVersion
    upstreamCompileOutput
    allSourceFiles
    compileClasspath
    javacOptions
    scalaOrganization
    allScalacOptions
    scalaCompilerClasspath
    scalacPluginClasspath
    zincReportCachedProblems

$ ./mill -i dev.run example/basic/1-simple-scala -i inspect console # command with no args
console(ScalaModule.scala:369)
    Opens up a Scala console with your module and all dependencies present,
    for you to test and operate your code interactively.

Inputs:
    scalaVersion
    runClasspath
    scalaCompilerClasspath
    forkArgs
    forkEnv
    forkWorkingDir

$ ./mill -i dev.run example/basic/1-simple-scala -i inspect ivyDepsTree # command with lots of args
ivyDepsTree(JavaModule.scala:688)
    Command to print the transitive dependency tree to STDOUT.

    --inverse              Invert the tree representation, so that the root is on the bottom val
                           inverse (will be forced when used with whatDependsOn)
    --whatDependsOn <str>  Possible list of modules (org:artifact) to target in the tree in order to
                           see where a dependency stems from.
    --withCompile          Include the compile-time only dependencies (`compileIvyDeps`, provided
                           scope) into the tree.
    --withRuntime          Include the runtime dependencies (`runIvyDeps`, runtime scope) into the
                           tree.

Inputs:
    transitiveIvyDeps
    scalaVersion
    scalaVersion
    scalaOrganization
    scalaVersion
```

I also removed the `numOverrides` field on `mill.define.Discover`, since
it's unused since #1600 landed a
while back
@lefou lefou added this to the 0.11.0-M9 milestone May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant