Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ulrs command #35

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- [Usage](#usage)
- [Generating Reports of Assignments](#generating-reports-of-assignments)
- [Cloning Repos](#cloning-repos)
- [Getting URLs](#getting-urls)
- [Seeding using a custom tool](#seeding-using-a-custom-tool)
- [Example using `seeder` Option](#example-using-seeder-option)
- [Using starter code as a template](#using-starter-code-as-a-template)
Expand Down Expand Up @@ -180,6 +181,7 @@ Usage:
Available Commands:
check check course config
clone Clone repositories.
completion Generate the autocompletion script for the specified shell
delete Delete repositories.
generate Generate repositories.
help Help about any command
Expand All @@ -188,6 +190,7 @@ Available Commands:
setaccess Set access level for exisiting repositories.
show Show config of an assignment
update Update repositories with code.
urls get urls for repositories
version Print the version number of Glabs

Flags:
Expand Down Expand Up @@ -263,6 +266,29 @@ glabs clone algdati blatt3 "grp0[35]" -fs | xargs code

clones the two repositories for `grp03` and `grp05` and opens them in VS Code.

## Getting URLs

```
get urls for repositories for each student or group in course for assignment.
You can specify students or groups in order to get an url only for these.

Usage:
glabs urls course assignment [groups...|students...] [flags]

Flags:
-h, --help help for urls

Global Flags:
--config string config file (default is $HOME/.glabs.yml)
-v, --verbose verbose output
```

This is useful for opening the webpages using a pipe, e.g.,

```
glabs urls algdati blatt3 grp15 | xargs open
```

## Seeding using a custom tool

Instead of providing each student/group the same repository using the startercode option it is possible to run a tool to seed each repository individually.
Expand Down
24 changes: 24 additions & 0 deletions cmd/urls.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cmd

import (
"github.com/obcode/glabs/config"
"github.com/spf13/cobra"
)

var (
urlsCmd = &cobra.Command{
Use: "urls course assignment [groups...|students...]",
Short: "get urls for repositories",
Long: `get urls for repositories for each student or group in course for assignment.
You can specify students or groups in order to get an url only for these.`,
Args: cobra.MinimumNArgs(2), //nolint:gomnd
Run: func(cmd *cobra.Command, args []string) {
assignmentConfig := config.GetAssignmentConfig(args[0], args[1], args[2:]...)
assignmentConfig.Urls()
},
}
)

func init() {
rootCmd.AddCommand(urlsCmd)
}
15 changes: 15 additions & 0 deletions config/urls.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package config

import "fmt"

func (cfg *AssignmentConfig) Urls() {
if cfg.Per == PerStudent {
for _, stud := range cfg.Students {
fmt.Printf("%s/%s-%s\n", cfg.URL, cfg.Name, cfg.RepoSuffix(stud))
}
} else { // PerGroup
for _, group := range cfg.Groups {
fmt.Printf("%s/%s-%s\n", cfg.URL, cfg.Name, group.Name)
}
}
}
Loading