Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.
/ ai Public archive

πŸͺ Simple CLI parser for Kotlin that won't make your head spin. 。.:β˜†*:ο½₯'(*βŒ’β€•βŒ’*)))

License

Notifications You must be signed in to change notification settings

noel-archive/ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸͺ ζ„› (ai)

Simple CLI parser for Kotlin that won't make your head spin. 。.:β˜†:ο½₯'(βŒ’β€•βŒ’)))*

πŸ“œ Documentation

WHY

ai (case-sensitive) was built out of frustration from the Kotlin CLI parsers out there like Clikt, kotlinx.cli, just to name a few.

With Clikt, I really had a hard time to build a proper CLI tool without running into errors when mixing flags and arguments and much more and I don't like the design for kotlinx-cli, while be minimal, just not for us.

ai was built to be really simple to build a CLI with a builder DSL or with OOP in mind. With Clikt, if you wanted to execute subcommands from the main [sub]command, you will need to do this:

object SomeCommand: CliktCommand(name = "name") {
  override fun run() {
    if (currentContext.invokedSubcommand == null) {
      // do code here for executing `./name`
    }
  }
}

With ai, you can create a robust CLI while arguments and flags are parsed by Apache Commons CLI.

Example

You can run the example in the example/ folder.

No Arguments

$ ./gradlew :example:run

Result

> Task :example:run
hi :DDDDD (arg=:D)

BUILD SUCCESSFUL in xms
5 actionable tasks: 1 executed, 4 up-to-date

With -a argument

$ ./gradlew :example:run --args="-a=."

Result

> Task :example:run
hi :DDDDD (arg=.)

BUILD SUCCESSFUL in xms
5 actionable tasks: 1 executed, 4 up-to-date

With h subcommand

> Task :example:run FAILED
USAGE :: example [COMMAND] [...ARGS]
> This command doesn't have a help section.

SUBCOMMANDS ::
  * example h [...ARGS] - This command doesn't have a help section.

OPTIONS ::
   -a, --aaaa <arg> heck!

Installation

Kotlin DSL

repositories {
    // If you're using the Noel Gradle Utils package, you can use the
    // `noelware` extension
    maven {
        url = uri("https://maven.noelware.org")
    }
}

dependencies {
    // If you're using the Noel Gradle Utils package, you can use
    // the `noelware` extension to automatically prefix `org.noelware.<module>`
    // in the dependency declaration
    implementation("org.noelware.ai:ai-<module_name>:<version>")
}

Groovy DSL

repositories {
    maven {
        url "https://maven.noelware.org"
    }
}

dependencies {
    implementation "org.noelware.ai:ai:<version>"
}

Maven

Declare the Noelware Maven repository under the <repositories> chain:

<repositories>
    <repository>
        <id>noelware-maven</id>
        <url>https://maven.noelware.org</url>
    </repository>
</repositories>

Now declare the dependency you want under the <dependencies> chain:

<dependencies>
    <dependency>
        <groupId>org.noelware.cli</groupId>
        <artifactId>ai</artifactId>
        <version>{{VERSION}}</version>
        <type>pom</type>
    </dependency>
</dependencies>

License

ai (ζ„›) is released under the MIT License with love πŸ’œ by Noelware (Β΄βˆ€ο½€)β™‘

About

πŸͺ Simple CLI parser for Kotlin that won't make your head spin. 。.:β˜†*:ο½₯'(*βŒ’β€•βŒ’*)))

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks