Add user login
This commit is contained in:
parent
05c38c4181
commit
756133cad0
2 changed files with 27 additions and 1 deletions
|
@ -8,11 +8,13 @@ version '0.1.0-SNAPSHOT'
|
|||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url 'https://jitpack.io' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||
|
||||
implementation 'com.github.wulkanowy:api:fe7ebc7c54'
|
||||
implementation 'com.github.ajalt:clikt:1.6.0'
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,35 @@
|
|||
package io.github.wulkanowy.cli
|
||||
|
||||
import com.github.ajalt.clikt.core.CliktCommand
|
||||
import com.github.ajalt.clikt.parameters.options.flag
|
||||
import com.github.ajalt.clikt.parameters.options.option
|
||||
import com.github.ajalt.clikt.parameters.options.prompt
|
||||
import io.github.wulkanowy.api.Api
|
||||
import okhttp3.logging.HttpLoggingInterceptor
|
||||
|
||||
class Hello : CliktCommand() {
|
||||
|
||||
private val debug by option().flag()
|
||||
|
||||
private val api = Api()
|
||||
|
||||
private val nick by option().prompt()
|
||||
|
||||
private val pass by option().prompt(hideInput = true)
|
||||
|
||||
override fun run() {
|
||||
echo("Hello World!")
|
||||
api.apply {
|
||||
logLevel = if (debug) HttpLoggingInterceptor.Level.BODY else HttpLoggingInterceptor.Level.NONE
|
||||
host = "vulcan.net.pl"
|
||||
email = nick
|
||||
password = pass
|
||||
}
|
||||
|
||||
echo("Ładowanie...")
|
||||
|
||||
val students = api.getStudents().blockingGet()
|
||||
echo("Znaleziono uczniów:")
|
||||
students.forEach { echo("${it.studentName} - ${it.description}") }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue