commands

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyTagResults

func ApplyTagResults(results ShikonaATag, r *sumomodel.Rikishi)

ApplyTagResults apply tag results to Rikishi

func IsRequestedDivision

func IsRequestedDivision(d []sumomodel.Division, str string) (int, bool)

IsRequestedDivision is used to check if a banzuke/ bout was requested by the user. it will return the division ID and true if it was requested.

func IsRequestedDivisionByID

func IsRequestedDivisionByID(d []sumomodel.Division, id int) bool

IsRequestedDivisionByID is used to check if a banzuke/ bout was requested by the user based on the ID provided.

Types

type BanzukeCommand

type BanzukeCommand struct {
	BanzukeFlags *flag.FlagSet
	// contains filtered or unexported fields
}

BanzukeCommand struct containing the Flags for the command and variables that the are used when parsing.

func NewBanzukeCommand

func NewBanzukeCommand(config sumoutils.Config) *BanzukeCommand

NewBanzukeCommand creates Banzuke Command and flagset.

func (*BanzukeCommand) CommandName

func (cmd *BanzukeCommand) CommandName() string

CommandName returns the name of the command

func (*BanzukeCommand) Parse

func (cmd *BanzukeCommand) Parse(osArgs []string) error

Parse the args received from the OS

func (*BanzukeCommand) Run

func (cmd *BanzukeCommand) Run() error

Run runs the BanzukeCommand by reaching out to the target URL and parsing the tables representing the banzuke.

type Command

type Command interface {

	// CommandName returns the name of the command.
	CommandName() string
	// Parse should parse the command and return any errors that occur during the process
	Parse([]string) error
	// Run should contain the logic to execute the desired command
	Run() error
}

Command required interface to be implemented by commands in order to function.

type DivisionFlag

type DivisionFlag []string

DivisionFlag an array of strings that are used to decide which divisions to target when scrapping. it implements the value interface from the flag package.

func (*DivisionFlag) Set

func (d *DivisionFlag) Set(s string) error

Set Division flag implementation of the Set(string) function required by the flags.Value interface

func (*DivisionFlag) String

func (d *DivisionFlag) String() string

type ShikonaATag

type ShikonaATag struct {
	Id         int
	Name       string
	Kanji      string
	Heya       string
	Shusshin   string
	Dob        string
	Firstbasho string
	Lastbasho  string
	HW         string
}

ShikonaATag the anchor elements store a portion of desired data in the title. This struct allows that data to be easily passed out of function and added to rikishi.

func (*ShikonaATag) ParseShikonaATag

func (s *ShikonaATag) ParseShikonaATag(element *colly.HTMLElement)

ParseShikonaATag takes a colly HtmlElement (which should be a td that contains an a tag with a title) then parses its contents and applies them to a shikonaATag

type TorikumiCommand

type TorikumiCommand struct {
	TorikumiFlagSet *flag.FlagSet
	// contains filtered or unexported fields
}

TorikumiCommand command and flagset to be executed.

func NewTorikumiCommand

func NewTorikumiCommand(config sumoutils.Config) *TorikumiCommand

NewTorikumiCommand returns a new ToeikumiCommand type

func (*TorikumiCommand) CommandName

func (cmd *TorikumiCommand) CommandName() string

CommandName returns command name.

func (*TorikumiCommand) Parse

func (cmd *TorikumiCommand) Parse(osArgs []string) error

Parse parses command arguments and returns an error if any of the values are invalid.

func (*TorikumiCommand) Run

func (cmd *TorikumiCommand) Run() error

Run logic to be executed when the torikumi command is called.

Jump to

Keyboard shortcuts

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