Started adding user list command
Signed-off-by: kolaente <k@knt.li>
This commit is contained in:
parent
4a70c81b33
commit
ed2ff62fd2
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
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)
|
||||||
|
},
|
||||||
|
}
|
Loading…
Reference in New Issue