diff --git a/src/client/git.v b/src/client/git.v index c21565a..280caab 100644 --- a/src/client/git.v +++ b/src/client/git.v @@ -1,14 +1,12 @@ module client -import db { GitRepo, GitRepoFilter } +import db { GitRepo } import net.http { Method } import response { Response } -import util // get_git_repos returns the current list of repos. -pub fn (c &Client) get_git_repos(filter GitRepoFilter) ?[]GitRepo { - params := util.struct_to_map(filter) - data := c.send_request<[]GitRepo>(Method.get, '/api/repos', params)? +pub fn (c &Client) get_git_repos() ?[]GitRepo { + data := c.send_request<[]GitRepo>(Method.get, '/api/repos', {})? return data.data } diff --git a/src/console/git/git.v b/src/console/git/git.v index 861bfb3..06d5f80 100644 --- a/src/console/git/git.v +++ b/src/console/git/git.v @@ -5,7 +5,6 @@ import env import cron.expression { parse_expression } import client import console -import db { GitRepoFilter } struct Config { address string [required] @@ -22,50 +21,11 @@ pub fn cmd() cli.Command { cli.Command{ name: 'list' description: 'List the current repos.' - flags: [ - cli.Flag{ - name: 'limit' - description: 'How many results to return.' - flag: cli.FlagType.int - }, - cli.Flag{ - name: 'offset' - description: 'Minimum index to return.' - flag: cli.FlagType.int - }, - cli.Flag{ - name: 'repo' - description: 'Only return Git repos that publish to this repo.' - flag: cli.FlagType.string - }, - cli.Flag{ - name: 'arch' - description: 'Only return repos enabled for this architecture.' - flag: cli.FlagType.string - }, - ] execute: fn (cmd cli.Command) ? { config_file := cmd.flags.get_string('config-file')? conf := env.load(config_file)? - mut filter := GitRepoFilter{} - - if limit := cmd.flags.get_int('limit') { - println('limit = $limit') - filter.limit = u64(limit) - } - - if offset := cmd.flags.get_int('offset') { - filter.limit = u64(offset) - } - - if repo := cmd.flags.get_string('repo') { - filter.repo = repo - } - - dump(filter) - - list(conf, filter)? + list(conf)? } }, cli.Command{ @@ -173,9 +133,9 @@ pub fn cmd() cli.Command { // ID. If multiple or none are found, an error is raised. // list prints out a list of all repositories. -fn list(conf Config, filter GitRepoFilter) ? { +fn list(conf Config) ? { c := client.new(conf.address, conf.api_key) - repos := c.get_git_repos(filter)? + repos := c.get_git_repos()? data := repos.map([it.id.str(), it.url, it.branch, it.repo]) println(console.pretty_table(['id', 'url', 'branch', 'repo'], data)?) diff --git a/src/db/filter.v b/src/db/filter.v index 07c890a..79e281b 100644 --- a/src/db/filter.v +++ b/src/db/filter.v @@ -1,6 +1,5 @@ module db -[params] pub struct GitRepoFilter { pub mut: limit u64 = 25 diff --git a/src/db/git.v b/src/db/git.v index 7308346..cb31bf0 100644 --- a/src/db/git.v +++ b/src/db/git.v @@ -78,7 +78,6 @@ pub fn git_repo_from_params(params map[string]string) ?GitRepo { // get_git_repos returns all GitRepo's in the database. pub fn (db &VieterDb) get_git_repos(filter GitRepoFilter) []GitRepo { - println(filter) // This seems to currently be blocked by a bug in the ORM, I'll have to ask // around. if filter.repo != '' { diff --git a/src/util/util.v b/src/util/util.v index cbb4072..266bcb5 100644 --- a/src/util/util.v +++ b/src/util/util.v @@ -64,13 +64,3 @@ pub fn pretty_bytes(bytes int) string { return '${n:.2}${util.prefixes[i]}' } - -pub fn struct_to_map(o T) map[string]string { - mut m := map[string]string{} - - $for field in T.fields { - m[field.name] = o.$(field.name).str() - } - - return m -}