// 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/>.
packagecmd
import(
"code.vikunja.io/api/pkg/initialize"
"code.vikunja.io/api/pkg/log"
"code.vikunja.io/api/pkg/user"
"fmt"
"github.com/olekukonko/tablewriter"
"github.com/spf13/cobra"
"golang.org/x/crypto/ssh/terminal"
"os"
"strconv"
"strings"
"time"
)
var(
userFlagUsernamestring
userFlagEmailstring
userFlagPasswordstring
userFlagAvatar="default"
userFlagResetPasswordDirectlybool
userFlagEnableUserbool
userFlagDisableUserbool
)
funcinit(){
// User create flags
userCreateCmd.Flags().StringVarP(&userFlagUsername,"username","u","","The username of the new user.")
_=userCreateCmd.MarkFlagRequired("username")
userCreateCmd.Flags().StringVarP(&userFlagEmail,"email","e","","The email address of the new user.")
_=userCreateCmd.MarkFlagRequired("email")
userCreateCmd.Flags().StringVarP(&userFlagPassword,"password","p","","The password of the new user. You will be asked to enter it if not provided through the flag.")
userCreateCmd.Flags().StringVarP(&userFlagAvatar,"avatar-provider","a","","The avatar provider of the new user. Optional.")
// User update flags
userUpdateCmd.Flags().StringVarP(&userFlagUsername,"username","u","","The new username of the user.")
userUpdateCmd.Flags().StringVarP(&userFlagEmail,"email","e","","The new email address of the user.")
userUpdateCmd.Flags().StringVarP(&userFlagAvatar,"avatar-provider","a","","The new avatar provider of the new user.")
// Reset PW flags
userResetPasswordCmd.Flags().BoolVarP(&userFlagResetPasswordDirectly,"direct","d",false,"If provided, reset the password directly instead of sending the user a reset mail.")
userResetPasswordCmd.Flags().StringVarP(&userFlagPassword,"password","p","","The new password of the user. Only used in combination with --direct. You will be asked to enter it if not provided through the flag.")
// Change status flags
userChangeEnabledCmd.Flags().BoolVarP(&userFlagDisableUser,"disable","d",false,"Disable the user.")
userChangeEnabledCmd.Flags().BoolVarP(&userFlagEnableUser,"enable","e",false,"Enable the user.")