@@ -28,13 +28,12 @@ import java.io.IOException
28
28
import java .net .InetAddress
29
29
import java .nio .file .Paths
30
30
import java .text .DecimalFormat
31
-
32
31
import com .fulcrumgenomics .bam .api .{SamSource , SamWriter }
33
32
import com .fulcrumgenomics .cmdline .FgBioMain .FailureException
34
33
import com .fulcrumgenomics .commons .CommonsDef ._
35
34
import com .fulcrumgenomics .commons .util .SystemUtil .IntelCompressionLibrarySupported
36
35
import com .fulcrumgenomics .commons .util .{LazyLogging , LogLevel , Logger }
37
- import com .fulcrumgenomics .sopt .cmdline .CommandLineProgramParserStrings
36
+ import com .fulcrumgenomics .sopt .cmdline .{ CommandLineParser , CommandLineProgramParserStrings }
38
37
import com .fulcrumgenomics .sopt .{Sopt , arg }
39
38
import com .fulcrumgenomics .util .Io
40
39
import com .fulcrumgenomics .vcf .api .VcfWriter
@@ -110,16 +109,27 @@ class FgBioMain extends LazyLogging {
110
109
}
111
110
112
111
val startTime = System .currentTimeMillis()
113
- val exit = Sopt .parseCommandAndSubCommand[FgBioCommonArgs ,FgBioTool ](name, args.toIndexedSeq, Sopt .find[FgBioTool ](packageList)) match {
112
+ val parser = new CommandLineParser [FgBioTool ](name) // Keep a reference to the parser so we can get the command line
113
+ val exit = parser.parseCommandAndSubCommand[FgBioCommonArgs ](args.toIndexedSeq, Sopt .find[FgBioTool ](packageList)) match {
114
114
case Sopt .Failure (usage) =>
115
115
System .err.print(usage())
116
116
1
117
- case Sopt .CommandSuccess (cmd ) =>
117
+ case Sopt .CommandSuccess (_ ) =>
118
118
unreachable(" CommandSuccess should never be returned by parseCommandAndSubCommand." )
119
119
case Sopt .SubcommandSuccess (commonArgs, subcommand) =>
120
120
FgBioCommonArgs .args = commonArgs
121
121
val name = subcommand.getClass.getSimpleName
122
122
try {
123
+ parser.commandLine.foreach { commandLine =>
124
+ parser.genericClpNameOnCommandLine
125
+ subcommand.toolInfo = FgBioToolInfo (
126
+ name = name,
127
+ args = this .name +: args.toIndexedSeq, // make sure to include the tool set name
128
+ commandLineWithDefaults = commandLine,
129
+ description = parser.formatShortDescription(Sopt .inspect(subcommand.getClass).description),
130
+ version = subcommand.getClass.getPackage.getImplementationVersion
131
+ )
132
+ }
123
133
printStartupLines(name, args, commonArgs)
124
134
subcommand.execute()
125
135
printEndingLines(startTime, name, true )
@@ -152,7 +162,6 @@ class FgBioMain extends LazyLogging {
152
162
153
163
/** Prints a line of useful information when a tool starts executing. */
154
164
protected def printStartupLines (tool : String , args : Array [String ], commonArgs : FgBioCommonArgs ): Unit = {
155
- val version = CommandLineProgramParserStrings .version(getClass, color= false ).replace(" Version: " , " " )
156
165
val host = try { InetAddress .getLocalHost.getHostName } catch { case _ : Exception => " unknown-host" }
157
166
val user = System .getProperty(" user.name" )
158
167
val jreVersion = System .getProperty(" java.runtime.version" )
@@ -172,4 +181,6 @@ class FgBioMain extends LazyLogging {
172
181
173
182
/** The packages we wish to include in our command line **/
174
183
protected def packageList : List [String ] = List [String ](" com.fulcrumgenomics" )
184
+
185
+ private def version : String = CommandLineProgramParserStrings .version(getClass, color= false ).replace(" Version: " , " " )
175
186
}
0 commit comments