diff --git a/docs/api/command-line.md b/docs/api/command-line.md index fae95dfa..b35a35a4 100644 --- a/docs/api/command-line.md +++ b/docs/api/command-line.md @@ -28,6 +28,8 @@ no extension for BBC micro program file, `.inf` for BBC Micro file metadata, `.asm` for assembly output, `.lbl`, `.nl`, `.fns`, or `.sym` for label file. +Default: If compiling one file with `.mfk` extension, the same name as the input file. Otherwise, `a`. + * `-s` – Generate also the assembly output. It is not compatible with any assembler, but it serves purely informational purpose. The file has the same nam as the output file and the extension is `.asm`. diff --git a/src/main/scala/millfork/Main.scala b/src/main/scala/millfork/Main.scala index 7e4042d9..cc2803f6 100644 --- a/src/main/scala/millfork/Main.scala +++ b/src/main/scala/millfork/Main.scala @@ -66,7 +66,14 @@ object Main { case (f, b) => errorReporting.debug(f" $f%-30s : $b%s") } - val output = c.outputFileName.getOrElse("a") + val output = c.outputFileName match { + case Some(ofn) => ofn + case None => c.inputFileNames match { + case List(ifn) if ifn.endsWith(".mfk") => + new File(ifn.stripSuffix(".mfk")).getName + case _ => "a" + } + } val assOutput = output + ".asm" // val prgOutputs = (platform.outputStyle match { // case OutputStyle.Single => List("default") @@ -369,10 +376,10 @@ object Main { fluff("Main options:", "") - parameter("-o", "--out").required().placeholder("").action { (p, c) => + parameter("-o", "--out").placeholder("").action { (p, c) => assertNone(c.outputFileName, "Output already defined") c.copy(outputFileName = Some(p)) - }.description("The output file name, without extension.").onWrongNumber(_ => errorReporting.fatalQuit("No output file specified")) + }.description("The output file name, without extension.") flag("-s").action { c => c.copy(outputAssembly = true)