2022-04-06 16:52:31 +02:00
|
|
|
module git
|
|
|
|
|
|
|
|
import cli
|
|
|
|
import env
|
|
|
|
import net.http
|
|
|
|
|
|
|
|
struct Config {
|
|
|
|
address string [required]
|
|
|
|
api_key string [required]
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn cmd() cli.Command {
|
|
|
|
return cli.Command{
|
|
|
|
name: 'repos'
|
|
|
|
description: 'Interact with the repos API.'
|
|
|
|
commands: [
|
2022-04-06 16:57:27 +02:00
|
|
|
cli.Command{
|
|
|
|
name: 'list'
|
|
|
|
description: 'List the current repos.'
|
|
|
|
execute: fn (cmd cli.Command) ? {
|
|
|
|
conf := env.load<Config>() ?
|
2022-04-06 16:52:31 +02:00
|
|
|
|
2022-04-06 16:57:27 +02:00
|
|
|
list(conf) ?
|
|
|
|
}
|
|
|
|
},
|
2022-04-06 16:52:31 +02:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn list(conf Config) ? {
|
|
|
|
mut req := http.new_request(http.Method.get, '$conf.address/api/repos', '') ?
|
|
|
|
req.add_custom_header('X-API-Key', conf.api_key) ?
|
|
|
|
|
|
|
|
res := req.do() ?
|
|
|
|
|
|
|
|
println(res.text)
|
|
|
|
}
|