35 lines
1,018 B
Swift
35 lines
1,018 B
Swift
|
// Login.swift
|
||
|
|
||
|
import Foundation
|
||
|
import ArgumentParser
|
||
|
import JellyfinAPI
|
||
|
|
||
|
extension Seanut {
|
||
|
struct LoginCommand: AsyncParsableCommand {
|
||
|
static var configuration = CommandConfiguration(
|
||
|
commandName: "login",
|
||
|
abstract: "Logs in as specified user to specified jellyfin server. caches access token for later invocations"
|
||
|
)
|
||
|
|
||
|
@OptionGroup var options: Seanut.CommonArguments
|
||
|
|
||
|
@Option(name: .shortAndLong, help: "username for the jellyfin server")
|
||
|
var username: String
|
||
|
|
||
|
@Option(name: .shortAndLong, help: "password for the jellyfin server")
|
||
|
var password: String?
|
||
|
|
||
|
mutating func run() async {
|
||
|
let client = JellyfinClient(
|
||
|
configuration: Seanut.generateJellyfinConfiguration(url: options.domain.toURL()!)
|
||
|
)
|
||
|
|
||
|
await Seanut.getAccessToken(
|
||
|
client: client,
|
||
|
username: username,
|
||
|
password: password
|
||
|
)
|
||
|
}
|
||
|
}
|
||
|
}
|