mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-25 22:07:56 +02:00
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:
parent
c21715d36b
commit
9449a29fb1
9 changed files with 29 additions and 51 deletions
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue