Skip to content

Commit

Permalink
Add docs for tokenize
Browse files Browse the repository at this point in the history
  • Loading branch information
ajalt committed Apr 28, 2024
1 parent 03dfd4c commit bec242f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ abstract class BaseCliktCommand<T : BaseCliktCommand<T>>(
*/
open val hiddenFromHelp: Boolean = false

// TODO: make these all private?
internal var _subcommands: List<T> = emptyList()
internal val _options: MutableList<Option> = mutableListOf()
internal val _arguments: MutableList<Argument> = mutableListOf()
Expand Down Expand Up @@ -265,7 +264,6 @@ abstract class BaseCliktCommand<T : BaseCliktCommand<T>>(
_groups += group
}

// TODO: all of these final functions could be extensions?
/**
* Return the help string for this command, optionally with an [error].
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,24 @@ import com.github.ajalt.clikt.output.defaultLocalization

// TODO: docs, changelog
object CommandLineParser {
/**
* Split a command line into a list of argv tokens.
*
* ### Example
* ```
* tokenize("--text 'hello world'") == listOf("--text", "hello world")
* ```
*
* @param commandLine The command line to split
* @param filename The name of the file being parsed. This is used in error messages.
* @param localization The localization to use for error messages
*/
fun tokenize(
commandLine: String,
filename: String = "",
localization: Localization = defaultLocalization,
): List<String> {
return shlex("TODO", commandLine, localization)// TODO shlex
return shlex(filename, commandLine, localization)
}

inline fun <T : BaseCliktCommand<T>> main(
Expand Down

0 comments on commit bec242f

Please sign in to comment.