Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
Useradm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Root
Useradm
Merge requests
!1
refactor: Reorganize into user and group commands
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
refactor: Reorganize into user and group commands
refactor
into
main
Overview
0
Commits
1
Pipelines
0
Changes
14
Merged
yyvf22
requested to merge
refactor
into
main
5 months ago
Overview
0
Commits
1
Pipelines
0
Changes
14
Expand
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
38adf7d8
1 commit,
5 months ago
14 files
+
267
−
168
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
14
Search (e.g. *.vue) (Ctrl+P)
cmd/group/create.go
0 → 100644
+
48
−
0
Options
package
group
import
(
"bufio"
"fmt"
"os"
"strings"
"github.com/spf13/cobra"
)
var
CreateCmd
=
&
cobra
.
Command
{
Use
:
"create"
,
Short
:
"Create new group"
,
RunE
:
createGroupFunc
,
}
func
init
()
{
CreateCmd
.
Flags
()
.
StringP
(
"groupname"
,
"e"
,
""
,
"Group name (use quotes for spaces)"
)
CreateCmd
.
Flags
()
.
BoolP
(
"confirm"
,
"y"
,
false
,
"Skip confirmation prompt"
)
CreateCmd
.
MarkFlagRequired
(
"groupname"
)
}
func
createGroupFunc
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
groupName
,
err
:=
cmd
.
Flags
()
.
GetString
(
"groupname"
)
if
err
!=
nil
{
return
err
}
confirm
,
err
:=
cmd
.
Flags
()
.
GetBool
(
"confirm"
)
if
err
!=
nil
{
return
err
}
fmt
.
Printf
(
"Groupname: %s
\n
"
,
groupName
)
if
!
confirm
{
fmt
.
Print
(
"Proceed with group creation? [y/N] "
)
reader
:=
bufio
.
NewReader
(
os
.
Stdin
)
response
,
_
:=
reader
.
ReadString
(
'\n'
)
if
strings
.
TrimSpace
(
strings
.
ToLower
(
response
))
!=
"y"
{
fmt
.
Println
(
"Aborted."
)
os
.
Exit
(
1
)
}
}
fmt
.
Println
(
"Done!"
)
return
nil
}
Loading