cmd

package
v0.0.0-...-4ba9c06 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2019 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConsoleCmd = &cobra.Command{
	Use:   "console",
	Short: "infomark console commands",
}

ConsoleCmd starts the infomark console

View Source
var RootCmd = &cobra.Command{
	Use:   "infomark",
	Short: "A CI based course framework",
	Long: `InfoMark is a a scalable, modern and open-source
online course management system supporting auto-testing/grading of
programming assignments and distributing exercise sheets.
The infomark-server is the REST api backend for the course distributing system.

Complete documentation is available at https://infomark.org/.
	`,
}

RootCmd represents the base command when called without any subcommands

View Source
var UtilsCmd = &cobra.Command{
	Use:   "utils",
	Short: "Some helper functions.",
}
View Source
var UtilsCompletionCmd = &cobra.Command{
	Use:   "completion [shell]",
	Short: "Output (bash/zsh) shell completion code",
	Long: `Pipe the stdout to your completion collection, e.g.,

./infomark console utils completion zsh > ~/.my-shell/completions/_infomark

`,

	Run: func(cmd *cobra.Command, args []string) {
		if len(args) != 1 {
			log.Fatalln("Expected one argument with the desired shell")
		}

		switch args[0] {
		case "bash":
			RootCmd.GenBashCompletion(os.Stdout)
		case "zsh":
			RootCmd.GenZshCompletion(os.Stdout)
		default:
			log.Fatalf("Unknown shell %s, only bash and zsh are available\n", args[0])
		}
	},
}
View Source
var UtilsDocCmd = &cobra.Command{
	Use:   "doc",
	Short: "Generates docs for console",

	Run: func(cmd *cobra.Command, args []string) {

		if len(args) != 1 {
			log.Fatalln("Expected one argument with the destination dir")
		}

		const fmTemplate = `---
date: %s
title: "%s"
slug: %s
url: %s
lastmod: %s
layout: subpagewithout
---

`

		filePrepender := func(filename string) string {
			now := time.Now().Format(time.RFC3339)
			name := filepath.Base(filename)
			base := strings.TrimSuffix(name, path.Ext(name))
			url := "/guides/console/commands/" + strings.ToLower(base) + "/"
			return fmt.Sprintf(fmTemplate, now, "Console", base, url, now)
		}

		linkHandler := func(name string) string {
			base := strings.TrimSuffix(name, path.Ext(name))
			return "/guides/console/commands/" + strings.ToLower(base) + "/"
		}

		err := doc.GenMarkdownTreeCustom(RootCmd, args[0], filePrepender, linkHandler)
		if err != nil {
			log.Fatal(err)
		}
	},
}

Functions

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func InitConfig

func InitConfig()

initConfig reads in config file and ENV variables if set.

func SetConfigFile

func SetConfigFile()

SetConfigFile searchs for a config file named ".informark.yml" which is located in the home-directory if the flag "--config" is not present.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL