From ed2ff62fd23e316c2f876ec039a2e85d7d9b6fda Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 12 Aug 2020 18:29:14 +0200 Subject: [PATCH] Started adding user list command Signed-off-by: kolaente --- pkg/cmd/user.go | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 pkg/cmd/user.go diff --git a/pkg/cmd/user.go b/pkg/cmd/user.go new file mode 100644 index 000000000..1910b6750 --- /dev/null +++ b/pkg/cmd/user.go @@ -0,0 +1,52 @@ +// Copyright 2020 Vikunja and contriubtors. All rights reserved. +// +// This file is part of Vikunja. +// +// Vikunja is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Vikunja is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Vikunja. If not, see . + +package cmd + +import ( + "code.vikunja.io/api/pkg/initialize" + "code.vikunja.io/api/pkg/log" + "code.vikunja.io/api/pkg/user" + "fmt" + "github.com/spf13/cobra" +) + +func init() { + userCmd.AddCommand(userListCmd) + rootCmd.AddCommand(userCmd) +} + +var userCmd = &cobra.Command{ + Use: "user", + Short: "Manage users locally through the cli.", +} + +var userListCmd = &cobra.Command{ + Use: "list", + Short: "Shows a list of all users on this instance.", + PreRun: func(cmd *cobra.Command, args []string) { + initialize.FullInit() + }, + Run: func(cmd *cobra.Command, args []string) { + users, err := user.ListUsers("") + if err != nil { + log.Criticalf("Error getting users: %s", err) + } + // TODO: Pretty print as ascii tables (only relevant stuff, exlude things like passwords + fmt.Println(users) + }, +}