Add user login

This commit is contained in:
Mikołaj Pich 2019-01-27 00:15:24 +01:00
parent 05c38c4181
commit 756133cad0
No known key found for this signature in database
GPG key ID: F62B26E36D4C4BAA
2 changed files with 27 additions and 1 deletions

View file

@ -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'
}

View file

@ -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}") }
}
}