summaryrefslogtreecommitdiff
path: root/cmd/gitlab-shell-authorized-principals-check/command/command.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/gitlab-shell-authorized-principals-check/command/command.go')
-rw-r--r--cmd/gitlab-shell-authorized-principals-check/command/command.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/cmd/gitlab-shell-authorized-principals-check/command/command.go b/cmd/gitlab-shell-authorized-principals-check/command/command.go
new file mode 100644
index 0000000..9418dad
--- /dev/null
+++ b/cmd/gitlab-shell-authorized-principals-check/command/command.go
@@ -0,0 +1,37 @@
+package command
+
+import (
+ "gitlab.com/gitlab-org/gitlab-shell/internal/command"
+ "gitlab.com/gitlab-org/gitlab-shell/internal/command/authorizedprincipals"
+ "gitlab.com/gitlab-org/gitlab-shell/internal/command/commandargs"
+ "gitlab.com/gitlab-org/gitlab-shell/internal/command/readwriter"
+ "gitlab.com/gitlab-org/gitlab-shell/internal/command/shared/disallowedcommand"
+ "gitlab.com/gitlab-org/gitlab-shell/internal/config"
+)
+
+func New(arguments []string, config *config.Config, readWriter *readwriter.ReadWriter) (command.Command, error) {
+ args, err := Parse(arguments)
+ if err != nil {
+ return nil, err
+ }
+
+ if cmd := build(args, config, readWriter); cmd != nil {
+ return cmd, nil
+ }
+
+ return nil, disallowedcommand.Error
+}
+
+func Parse(arguments []string) (*commandargs.AuthorizedPrincipals, error) {
+ args := &commandargs.AuthorizedPrincipals{Arguments: arguments}
+
+ if err := args.Parse(); err != nil {
+ return nil, err
+ }
+
+ return args, nil
+}
+
+func build(args *commandargs.AuthorizedPrincipals, config *config.Config, readWriter *readwriter.ReadWriter) command.Command {
+ return &authorizedprincipals.Command{Config: config, Args: args, ReadWriter: readWriter}
+}