-
-
Notifications
You must be signed in to change notification settings - Fork 368
Expand file tree
/
Copy pathopen.go
More file actions
30 lines (26 loc) · 740 Bytes
/
open.go
File metadata and controls
30 lines (26 loc) · 740 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package cmd
import (
"github.com/exercism/cli/browser"
"github.com/exercism/cli/workspace"
"github.com/spf13/cobra"
)
// openCmd opens the designated exercise in the browser.
var openCmd = &cobra.Command{
Use: "open",
Aliases: []string{"o"},
Short: "Open an exercise on the website.",
Long: `Open the specified exercise to the solution page on the Exercism website.
Pass the path to the directory that contains the solution you want to see on the website.
`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
metadata, err := workspace.NewExerciseMetadata(args[0])
if err != nil {
return err
}
return browser.Open(metadata.URL)
},
}
func init() {
RootCmd.AddCommand(openCmd)
}