service auth, edit and delete now all support --service flag

If a service name is given, this will be used. If not the user is
prompted to select one.
This commit is contained in:
Philipp Wolfer 2023-12-09 22:59:33 +01:00
parent c21715d36b
commit 9449a29fb1
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B
9 changed files with 29 additions and 51 deletions

View file

@ -17,7 +17,6 @@ Scotty. If not, see <https://www.gnu.org/licenses/>.
package cmd
import (
"errors"
"fmt"
"os"
@ -42,11 +41,8 @@ var serviceAuthCmd = &cobra.Command{
Authentication is always done per configured service. That means you can have
multiple services using the same backend but different authentication.`,
Run: func(cmd *cobra.Command, args []string) {
serviceConfig := cli.GetServiceConfigFromFlag(cmd, "service")
if serviceConfig == nil {
err := errors.New(i18n.Tr("failed loading service configuration"))
cobra.CheckErr(err)
}
serviceConfig, err := cli.SelectService(cmd)
cobra.CheckErr(err)
backend, err := backends.ResolveBackend[models.OAuth2Authenticator](serviceConfig)
cobra.CheckErr(err)
@ -97,7 +93,5 @@ multiple services using the same backend but different authentication.`,
func init() {
serviceCmd.AddCommand(serviceAuthCmd)
serviceAuthCmd.Flags().StringP("service", "s", "", "service configuration (required)")
serviceAuthCmd.MarkFlagRequired("service")
serviceAuthCmd.Flags().StringP("service", "s", "", "service configuration")
}