-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
162 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/obcode/glabs/config" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func init() { | ||
rootCmd.AddCommand(showConfigCmd) | ||
} | ||
|
||
var showConfigCmd = &cobra.Command{ | ||
Use: "show course assignment [groups...|students...]", | ||
Short: "Show config of an assignment", | ||
Long: `Show config of an assignment`, | ||
Args: cobra.MinimumNArgs(2), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
cfg := config.GetAssignmentConfig(args[0], args[1], args[2:]...) | ||
cfg.Show() | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package config | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/gookit/color" | ||
) | ||
|
||
func (cfg *AssignmentConfig) Show() { | ||
containerRegistry := "disabled" | ||
if cfg.ContainerRegistry { | ||
containerRegistry = "enabled" | ||
} | ||
|
||
startercode := "---" | ||
if cfg.Startercode != nil { | ||
startercode = fmt.Sprintf(` | ||
URL: %s | ||
FromBranch: %s | ||
ToBranch: %s | ||
ProtectToBranch: %t`, | ||
cfg.Startercode.URL, | ||
cfg.Startercode.FromBranch, | ||
cfg.Startercode.ToBranch, | ||
cfg.Startercode.ProtectToBranch, | ||
) | ||
} | ||
|
||
var per strings.Builder | ||
switch cfg.Per { | ||
case PerStudent: | ||
per.WriteString("Students:\n") | ||
for _, s := range cfg.Students { | ||
per.WriteString(" - ") | ||
per.WriteString(s) | ||
per.WriteString("\n") | ||
} | ||
case PerGroup: | ||
per.WriteString("Groups:\n") | ||
for _, grp := range cfg.Groups { | ||
per.WriteString(" - ") | ||
per.WriteString(grp.Name) | ||
per.WriteString(": ") | ||
for i, m := range grp.Members { | ||
per.WriteString(m) | ||
if i == len(grp.Members)-1 { | ||
per.WriteString("\n") | ||
} else { | ||
per.WriteString(", ") | ||
} | ||
} | ||
} | ||
} | ||
|
||
groupsOrStudents := per.String() | ||
|
||
color.Cyan.Printf(` | ||
Course: %s | ||
Assignment: %s | ||
Per: %s | ||
Base-URL: %s | ||
Description: %s | ||
AccessLevel: %s | ||
Container-Registry: %s | ||
Startercode:%s | ||
%s | ||
`, | ||
cfg.Course, | ||
cfg.Name, | ||
cfg.Per, | ||
cfg.URL, | ||
cfg.Description, | ||
cfg.AccessLevel.show(), | ||
containerRegistry, | ||
startercode, | ||
groupsOrStudents, | ||
) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters