Skip to content

Commit

Permalink
team: add -L to show language
Browse files Browse the repository at this point in the history
Signed-off-by: Jiang Xin <[email protected]>
  • Loading branch information
jiangxin committed Apr 19, 2024
1 parent 41c851b commit 6838591
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
5 changes: 5 additions & 0 deletions cmd/team.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,17 @@ func (v *teamCommand) Command() *cobra.Command {
"m",
false,
"show all users")
v.cmd.Flags().BoolP("language",
"L",
false,
"show language")
v.cmd.Flags().BoolP("check",
"c",
false,
"show all users")
_ = viper.BindPFlag("team-leader", v.cmd.Flags().Lookup("leader"))
_ = viper.BindPFlag("team-members", v.cmd.Flags().Lookup("members"))
_ = viper.BindPFlag("show-language", v.cmd.Flags().Lookup("language"))
_ = viper.BindPFlag("team-check", v.cmd.Flags().Lookup("check"))
return v.cmd
}
Expand Down
24 changes: 15 additions & 9 deletions util/team.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,12 @@ func ParseTeams(fileName string) ([]Team, []error) {
// ShowTeams will show leader/members of a team.
func ShowTeams(args ...string) bool {
var (
teams []Team
errors []error
optLeader = viper.GetBool("team-leader")
optMembers = viper.GetBool("team-members")
ret = true
teams []Team
errors []error
optLeader = viper.GetBool("team-leader")
optMembers = viper.GetBool("team-members")
optLanguage = viper.GetBool("show-language")
ret = true
)
teams, errors = ParseTeams("")
if len(errors) != 0 {
Expand All @@ -204,15 +205,20 @@ func ShowTeams(args ...string) bool {
return ret
}
for _, team := range teams {
if optLeader || optMembers {
fmt.Printf("%s <%s>\n", team.Leader.Name, team.Leader.Email)
prefix := ""
if optLanguage {
fmt.Printf("%s:\n", team.Language)
prefix = "\t"
}
if (optLeader || optMembers) && team.Leader.Name != "" {
fmt.Printf("%s%s <%s>\n", prefix, team.Leader.Name, team.Leader.Email)
}
if optMembers {
for _, member := range team.Members {
fmt.Printf("%s <%s>\n", member.Name, member.Email)
fmt.Printf("%s%s <%s>\n", prefix, member.Name, member.Email)
}
}
if !optLeader && !optMembers {
if !optLeader && !optMembers && !optLanguage {
fmt.Println(team.Language)
}
}
Expand Down

0 comments on commit 6838591

Please sign in to comment.