5. Shell (computing)
—
a shell is a computer program which exposes an operating
system's services to a human user or other program.
— From Wikipedia
GUI
CLI
19. —
class Hello: CliktCommand() {
override fun run() {
echo("Hello World!")
}
}
fun main(args: Array<String>) = Hello().main(args)
20. Command
—
class Database: CliktCommand() {
override fun run() = Unit
}
class Init: CliktCommand(help="Initialize the database") {
override fun run() {
echo("Initialized the database.")
}
}
class Drop: CliktCommand(help="Drop the database") {
override fun run() {
echo("Dropped the database.")
}
}
fun main(args: Array<String>) = Database()
.subcommands(Init(), Drop())
.main(args)
21. Argument
—
class Hello : CliktCommand() {
val name by argument()
override fun run() {
echo("Hello $name!")
}
}
22. Option
—
class Hello : CliktCommand() {
val count by option(help="Number of greetings")
.int()
.default(1)
val name by argument()
override fun run() {
for (i in 1..count) {
echo("Hello $name!")
}
}
}