Skip to content

Commit

Permalink
Update plugins sample
Browse files Browse the repository at this point in the history
  • Loading branch information
ajalt committed Apr 14, 2024
1 parent 92c489d commit d525a6c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.ajalt.clikt.samples.plugins

import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.Context
import com.github.ajalt.clikt.core.requireObject
import com.github.ajalt.clikt.parameters.arguments.argument
import com.github.ajalt.clikt.parameters.arguments.optional
Expand All @@ -13,14 +14,15 @@ import org.kodein.di.generic.inSet
import org.kodein.di.generic.provider
import java.io.File

class Clone : CliktCommand(
help = """
Clones a repository.
class Clone : CliktCommand() {
override fun help(context: Context) = """
Clones a repository.
This will clone the repository at SRC into the folder DEST. If DEST
is not provided this will automatically use the last path component
of SRC and create that folder.
""".trimIndent()

This will clone the repository at SRC into the folder DEST. If DEST
is not provided this will automatically use the last path component
of SRC and create that folder.
""".trimIndent()) {
val repo: Repo by requireObject()
val src: String by argument()
val dest: String? by argument().optional()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.ajalt.clikt.samples.plugins

import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.Context
import com.github.ajalt.clikt.core.main
import com.github.ajalt.clikt.core.subcommands
import com.github.ajalt.clikt.parameters.options.*
Expand All @@ -11,14 +12,15 @@ import org.kodein.di.generic.setBinding

data class Repo(var home: String, val config: MutableMap<String, String>, var verbose: Boolean)

class Cli : CliktCommand(
help = """
Repo is a command line tool that showcases how to build complex
command line interfaces with Clikt.
class Cli : CliktCommand() {
override fun help(context: Context) = """
Repo is a command line tool that showcases how to build complex
command line interfaces with Clikt.
This tool is supposed to look like a distributed version control
system to show how something like this can be structured.
""".trimIndent()

This tool is supposed to look like a distributed version control
system to show how something like this can be structured.
""".trimIndent()) {
init {
versionOption("1.0")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.ajalt.clikt.samples.plugins

import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.Context
import com.github.ajalt.clikt.core.requireObject
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.options.prompt
Expand All @@ -9,13 +10,13 @@ import org.kodein.di.generic.bind
import org.kodein.di.generic.inSet
import org.kodein.di.generic.provider

class SetUser : CliktCommand(
name = "setuser",
help = """
Sets the user credentials.
class SetUser : CliktCommand(name = "setuser") {
override fun help(context: Context) = """
Sets the user credentials.
This will override the current user config.
""".trimIndent()

This will override the current user config.
""".trimIndent()) {
val repo: Repo by requireObject()
val username: String by option(help = "The developer's shown username.")
.prompt()
Expand Down

0 comments on commit d525a6c

Please sign in to comment.