config

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package config contains structures and functions for contest and application config

Package config contains structures and functions for contest and application config

Package config contains structures and functions for contest and application config

Index

Constants

This section is empty.

Variables

View Source
var TestDir string = "temp"

Functions

This section is empty.

Types

type ApplicationConfig

type ApplicationConfig struct {
	Port          string
	ConfigPath    string
	LanguagesPath string
	Generate      bool
}

AplicationConfig represents config for application Port is listening port for the web server ConfigPath is path to the config for the contest LanguagesPath is path to the config for the programming languages If Generate is true that application will generate new contest, otherwise that will use existing contest

func ParseArgs

func ParseArgs() *ApplicationConfig

ParseArgs parses arguments from command line returns pointer to ApplicationConfig that constructued from command line arguments

type Config

type Config struct {
	TestsInfo map[string]struct {
		Path       string `json:"path"`
		TestsCount int    `json:"count"`
	} `json:"tests"`
	OutputPath  string `json:"outputPath"`
	StartTime   string `json:"startTime"`
	Contestants []struct {
		Id   string `json:"id"`
		Name string `json:"name"`
	} `json:"contestants"`
	Credentials map[string]struct {
		Id       string `json:"id"`
		Password string `json:"password"`
		Role     string `json:"role"`
	} `json:"credentials"`
	Problems []string `json:"problems"`
	Duration int64    `json:"duration"`
}

Config represents information about the contest. TestsInfo represents information about count of the test and path to the directory with tests OutputPath represents path to output json file with contest info StartTime represents start time of the contest Contestans represents basic information about contestans Name and Id Credentials represents id/login/password/role for every contestant (Role = user/admin) Problems represents array of the problem names in the contest. For example: ["A", "B", "C"] Duration is duration of the contest in seconds

var TestConfig *Config

func ParseConfig

func ParseConfig(path string) (*Config, error)

ParseConfig parses Config from json file with specified path.

func (*Config) GetTestPathForProblem

func (c *Config) GetTestPathForProblem(problem string) (string, int, error)

GetTestPathForProblem returns path to the folder with tests and count of tests for the specified problem

type Language

type Language struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

Langauge represents information about programming language Name is a full name of programming language Value is a short name of programming language For example: Name = "C++ 20 (gcc)", Value = "cpp20"

type Languages

type Languages struct {
	Langs        []Language        `json:"languages"`
	CompileFiles map[string]string `json:"compileFiles"`
}

Languages represents information about all using programming languages in the contest Langs is array of Language with base information about each language CompileFiles is map that associate short name of the programming language with path to the compilation shell script

var LangaugesConfig *Languages

func ParseLangauges

func ParseLangauges(path string) (*Languages, error)

ParseLanguages parses Languages from the specifed json file. returns pointer to Languages

func (*Languages) GetCompileFileName

func (l *Languages) GetCompileFileName(language string) string

GetCompileFileName returns path to the compilation shell script for the specified programming languages language specifies programming language

func (*Languages) GetLanguages

func (l *Languages) GetLanguages() []Language

GetLangauges returns array of basic information about programming languages in the contest as array of Language

Jump to

Keyboard shortcuts

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