Skip to content

Commit

Permalink
Replace \n with File.separator
Browse files Browse the repository at this point in the history
  • Loading branch information
juraj-hrivnak committed Aug 27, 2024
1 parent c5d0e62 commit ae220e3
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 57 deletions.
26 changes: 13 additions & 13 deletions src/commonMain/kotlin/teksturepako/pakku/cli/cmd/Diff.kt
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ class Diff : CliktCommand("Diff projects in modpack")

file.createNewFile()
file.outputStream().close()
file.appendText("```diff\n")
added.forEach { file.appendText("+ $it\n") }
removed.forEach { file.appendText("- $it\n") }
updated.forEach { file.appendText("! $it\n") }
file.appendText("```\n")
file.appendText("```diff${File.separator}")
added.forEach { file.appendText("+ $it${File.separator}") }
removed.forEach { file.appendText("- $it${File.separator}") }
updated.forEach { file.appendText("! $it${File.separator}") }
file.appendText("```${File.separator}")
}

if (markdownOpt != null)
Expand All @@ -129,20 +129,20 @@ class Diff : CliktCommand("Diff projects in modpack")
file.outputStream().close()
if (added.isNotEmpty())
{
file.appendText("### Added\n")
added.forEach { file.appendText("- $it\n") }
if (removed.isNotEmpty()) file.appendText("\n")
file.appendText("### Added${File.separator}")
added.forEach { file.appendText("- $it${File.separator}") }
if (removed.isNotEmpty()) file.appendText(File.separator)
}
if (removed.isNotEmpty())
{
file.appendText("### Removed\n")
removed.forEach { file.appendText("- $it\n") }
if (updated.isNotEmpty()) file.appendText("\n")
file.appendText("### Removed${File.separator}")
removed.forEach { file.appendText("- $it${File.separator}") }
if (updated.isNotEmpty()) file.appendText(File.separator)
}
if (updated.isNotEmpty())
{
file.appendText("### Updated\n")
updated.forEach { file.appendText("- $it\n") }
file.appendText("### Updated${File.separator}")
updated.forEach { file.appendText("- $it${File.separator}") }
}
}
echo()
Expand Down
87 changes: 43 additions & 44 deletions src/commonMain/kotlin/teksturepako/pakku/cli/cmd/Pakku.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ import teksturepako.pakku.cli.ui.overrideYes
import teksturepako.pakku.cli.ui.pInfo
import teksturepako.pakku.debugMode
import teksturepako.pakku.io.tryOrNull
import java.io.File
import kotlin.io.path.*
import kotlin.system.exitProcess

class Pakku : CliktCommand()
{
init {
init
{
versionOption(VERSION, help = "Get pakku version")
completionOption(help = "Generate autocompletion scripts")
eagerOption(
Expand All @@ -29,16 +31,13 @@ class Pakku : CliktCommand()
}

private val yesFlag: Boolean by option(
"-y", "--yes",
help = "Overwrite every prompt to 'yes' without asking"
"-y", "--yes", help = "Overwrite every prompt to 'yes' without asking"
).flag()

private val debugFlag: Boolean by option("--debug", help = "Enable additional debug logging").flag()

private val workingPathOpt: String? by option(
"--working-path",
help = "Change the working path of Pakku",
metavar = "<path>"
"--working-path", help = "Change the working path of Pakku", metavar = "<path>"
)

override fun run()
Expand Down Expand Up @@ -83,26 +82,26 @@ suspend fun CliktCommand.generateDocs(context: OptionTransformContext)
val helpOpt = subcmd.registeredOptions().find { "--help" in it.names }

val text = buildString {
append("# pakku $cmdName\n")
append("\n")
append("$cmdHelp\n")
append("\n")
append("## Usage\n")
append("\n")
append("<snippet id=\"snippet-cmd\">\n")
append("\n")
append("<var name=\"cmd\">$cmdName</var>\n")
append("<var name=\"params\">$cmdParams</var>\n")
append("<include from=\"_template_cmd.md\" element-id=\"template-cmd\"/>\n")
append("\n")
append("</snippet>\n")
append("\n")
append("# pakku $cmdName${File.separator}")
append(File.separator)
append("$cmdHelp${File.separator}")
append(File.separator)
append("## Usage${File.separator}")
append(File.separator)
append("<snippet id=\"snippet-cmd\">${File.separator}")
append(File.separator)
append("<var name=\"cmd\">$cmdName</var>${File.separator}")
append("<var name=\"params\">$cmdParams</var>${File.separator}")
append("<include from=\"_template_cmd.md\" element-id=\"template-cmd\"/>${File.separator}")
append(File.separator)
append("</snippet>${File.separator}")
append(File.separator)
if (args.isNotEmpty())
{
append("## Arguments\n")
append("\n")
append("<snippet id=\"snippet-args\">\n")
append("\n")
append("## Arguments${File.separator}")
append(File.separator)
append("<snippet id=\"snippet-args\">${File.separator}")
append(File.separator)
for (arg in args)
{
val argName = buildString {
Expand All @@ -115,42 +114,42 @@ suspend fun CliktCommand.generateDocs(context: OptionTransformContext)
}
val argHelp = arg.help.ifBlank { "The `${arg.name.lowercase()}` argument" }

append("$argName\n")
append(": $argHelp\n")
append("\n")
append("$argName${File.separator}")
append(": $argHelp${File.separator}")
append(File.separator)
}
append("</snippet>\n")
append("\n")
append("</snippet>${File.separator}")
append(File.separator)
}
append("## Options\n")
append("\n")
append("<snippet id=\"snippet-options-all\">\n")
append("\n")
append("## Options${File.separator}")
append(File.separator)
append("<snippet id=\"snippet-options-all\">${File.separator}")
append(File.separator)
if (opts.isNotEmpty())
{
append("<snippet id=\"snippet-options\">\n")
append("\n")
append("<snippet id=\"snippet-options\">${File.separator}")
append(File.separator)
for (opt in opts)
{
val optName = opt.names.joinToString { "`$it`" }
val optHelp = opt.optionHelp(context.context)

append("$optName\n")
append(": $optHelp\n")
append("\n")
append("$optName${File.separator}")
append(": $optHelp${File.separator}")
append(File.separator)
}
append("</snippet>\n")
append("\n")
append("</snippet>${File.separator}")
append(File.separator)
}
helpOpt?.let { opt ->
val optName = opt.names.joinToString { "`$it`" }
val optHelp = opt.optionHelp(context.context)

append("$optName\n")
append(": $optHelp\n")
append("\n")
append("$optName${File.separator}")
append(": $optHelp${File.separator}")
append(File.separator)
}
append("</snippet>\n")
File("</snippet>${File.separator}")
append("")
}

Expand Down

0 comments on commit ae220e3

Please sign in to comment.