forked from vieter-v/vieter
Migrated rest of cli commands
This commit is contained in:
parent
9dd02426ff
commit
21ef262ede
2 changed files with 40 additions and 84 deletions
|
|
@ -23,6 +23,28 @@ pub fn cmd() cli.Command {
|
|||
list(conf) ?
|
||||
}
|
||||
},
|
||||
cli.Command{
|
||||
name: 'add'
|
||||
required_args: 2
|
||||
usage: 'url branch'
|
||||
description: 'Add a new repository.'
|
||||
execute: fn (cmd cli.Command) ? {
|
||||
conf := env.load<Config>() ?
|
||||
|
||||
add(conf, cmd.args[0], cmd.args[1]) ?
|
||||
}
|
||||
},
|
||||
cli.Command{
|
||||
name: 'remove'
|
||||
required_args: 2
|
||||
usage: 'url branch'
|
||||
description: 'Remove a repository.'
|
||||
execute: fn (cmd cli.Command) ? {
|
||||
conf := env.load<Config>() ?
|
||||
|
||||
remove(conf, cmd.args[0], cmd.args[1]) ?
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
@ -35,3 +57,21 @@ fn list(conf Config) ? {
|
|||
|
||||
println(res.text)
|
||||
}
|
||||
|
||||
fn add(conf Config, url string, branch string) ? {
|
||||
mut req := http.new_request(http.Method.post, '$conf.address/api/repos?url=$url&branch=$branch', '') ?
|
||||
req.add_custom_header('X-API-Key', conf.api_key) ?
|
||||
|
||||
res := req.do() ?
|
||||
|
||||
println(res.text)
|
||||
}
|
||||
|
||||
fn remove(conf Config, url string, branch string) ? {
|
||||
mut req := http.new_request(http.Method.delete, '$conf.address/api/repos?url=$url&branch=$branch', '') ?
|
||||
req.add_custom_header('X-API-Key', conf.api_key) ?
|
||||
|
||||
res := req.do() ?
|
||||
|
||||
println(res.text)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue