commands

package
v0.2.1 Latest Latest
Warning

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

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

Documentation

Overview

package commands contains commands that can be executed by the CLI.

Index

Constants

This section is empty.

Variables

View Source
var BankAccountCmd = &cli.Command{
	Name:   "bank-account",
	Usage:  "Manage bank accounts",
	Before: mcli.InjectSession,
	Commands: []*cli.Command{
		{
			Name:   "create",
			Usage:  "Creates a new bank account",
			Action: CreateBankAccount,
			Flags: []cli.Flag{
				&cli.StringFlag{Name: "name", Usage: "The identifier of the portfolio, e.g. mybank-myportfolio", Required: true},
				&cli.StringFlag{Name: "display-name", Usage: "The display name of the portfolio"},
			},
		},
	},
}

BankAccountCmd is the command for bank account related commands.

View Source
var CLICmd = &cli.Command{
	Name:                  "mgo",
	Usage:                 "The money-gopher CLI",
	EnableShellCompletion: true,
	Flags: []cli.Flag{
		&cli.BoolFlag{Name: "debug", Usage: "Enable debug mode."},
	},
	Commands: []*cli.Command{
		PortfolioCmd,
		SecuritiesCmd,
		BankAccountCmd,
		LoginCmd,
	},
}

CLICmd is the main CLICmd command.

View Source
var LoginCmd = &cli.Command{
	Name:   "login",
	Usage:  "Login to the Money Gopher server",
	Action: Login,
	Flags: []cli.Flag{
		&cli.StringFlag{Name: "client-id", Usage: "The client ID to use for the OAuth 2.0 flow", Value: "cli"},
		&cli.StringFlag{Name: "auth-url", Usage: "The authorization URL for the OAuth 2.0 flow", Value: "http://localhost:8000/authorize"},
		&cli.StringFlag{Name: "token-url", Usage: "The token URL for the OAuth 2.0 flow", Value: "http://localhost:8000/token"},
		&cli.StringFlag{Name: "callback", Usage: "The callback URL for the OAuth 2.0 flow", Value: "http://localhost:10000/callback"},
	},
}

LoginCmd is the command to login to the Money Gopher server.

View Source
var PortfolioCmd = &cli.Command{
	Name:   "portfolio",
	Usage:  "Manage portfolios and transactions",
	Before: mcli.InjectSession,
	Commands: []*cli.Command{
		{
			Name:   "create",
			Usage:  "Creates a new portfolio",
			Action: CreatePortfolio,
			Flags: []cli.Flag{
				&cli.StringFlag{Name: "name", Usage: "The identifier of the portfolio, e.g. mybank-myportfolio", Required: true},
				&cli.StringFlag{Name: "display-name", Usage: "The display name of the portfolio"},
			},
		},
		{
			Name:   "list",
			Usage:  "Lists all portfolios",
			Action: ListPortfolio,
			Flags:  []cli.Flag{},
		},
		{
			Name:   "show",
			Usage:  "Shows details about one portfolio",
			Action: ShowPortfolio,
			Flags: []cli.Flag{
				&cli.StringFlag{Name: "portfolio-name", Usage: "The identifier of the portfolio, e.g. mybank-myportfolio", Required: true},
			},
		},
		{
			Name:  "transactions",
			Usage: "Subcommands supporting transactions within one portfolio",
			Commands: []*cli.Command{
				{
					Name:   "create",
					Usage:  "Creates a transaction. Defaults to a \"buy\" transaction",
					Action: CreateTransaction,
					Flags: []cli.Flag{
						&cli.StringFlag{Name: "portfolio-name", Usage: "The name of the portfolio where the transaction will be created in", Required: true},
						&cli.StringFlag{Name: "security-name", Usage: "The name of the security this transaction belongs to (its ISIN)", Required: true},
						&cli.StringFlag{Name: "type", Usage: "The type of the transaction", Required: true, DefaultText: "buy"},
						&cli.FloatFlag{Name: "amount", Usage: "The amount of securities involved in the transaction", Required: true},
						&cli.FloatFlag{Name: "price", Usage: "The price without fees or taxes", Required: true},
						&cli.FloatFlag{Name: "fees", Usage: "Any fees that applied to the transaction"},
						&cli.FloatFlag{Name: "taxes", Usage: "Any taxes that applied to the transaction"},
						&cli.StringFlag{Name: "time", Usage: "The time of the transaction. Defaults to 'now'", DefaultText: "now"},
					},
				},
				{
					Name:   "import",
					Usage:  "Imports transactions from CSV",
					Action: ImportTransactions,
					Flags: []cli.Flag{
						&cli.StringFlag{Name: "portfolio-name", Usage: "The name of the portfolio where the transaction will be created in", Required: true},
						&cli.StringFlag{Name: "csv-file", Usage: "The path to the CSV file to import", Required: true},
					},
				},
			},
		},
	},
}

PortfolioCmd is the command for portfolio related commands.

View Source
var SecuritiesCmd = &cli.Command{
	Name:   "securities",
	Usage:  "Securities commands",
	Before: mcli.InjectSession,
	Commands: []*cli.Command{
		{
			Name:   "list",
			Usage:  "Lists all securities",
			Action: ListSecurities,
		},
		{
			Name:   "update-quote",
			Usage:  "Triggers an update of one or more securities' quotes",
			Action: UpdateQuote,
			Flags: []cli.Flag{
				&cli.StringSliceFlag{Name: "security-names", Usage: "The security IDs to update", Required: true},
			},
			EnableShellCompletion: true,
			ShellComplete:         PredictSecurities,
		},
		{
			Name:   "update-all-quotes",
			Usage:  "Triggers an update of all quotes",
			Action: UpdateAllQuotes,
		},
	},
}

SecuritiesCmd is the command for security related commands.

View Source
var (
	// VerifierGenerator is a function that generates a new verifier.
	VerifierGenerator = oauth2.GenerateSecret
)

Functions

func CreateBankAccount added in v0.2.1

func CreateBankAccount(ctx context.Context, cmd *cli.Command) error

CreateBankAccount creates a new bank account.

func CreatePortfolio added in v0.2.1

func CreatePortfolio(ctx context.Context, cmd *cli.Command) error

CreatePortfolio creates a new portfolio.

func CreateTransaction added in v0.2.1

func CreateTransaction(ctx context.Context, cmd *cli.Command) error

CreateTransaction creates a transaction.

func ImportTransactions added in v0.2.1

func ImportTransactions(ctx context.Context, cmd *cli.Command) error

ImportTransactions imports transactions from a CSV file

func ListPortfolio added in v0.2.1

func ListPortfolio(ctx context.Context, cmd *cli.Command) error

ListPortfolio lists all portfolios.

func ListSecurities added in v0.2.1

func ListSecurities(ctx context.Context, cmd *cli.Command) error

ListSecurities lists all securities.

func Login added in v0.2.1

func Login(ctx context.Context, cmd *cli.Command) error

Login is the action for the login command.

func PredictPortfolios

func PredictPortfolios(ctx context.Context, cmd *cli.Command)

PredictPortfolios predicts the portfolios for shell completion.

func PredictSecurities added in v0.0.4

func PredictSecurities(ctx context.Context, cmd *cli.Command)

PredictSecurities predicts the securities for shell completion.

func ShowPortfolio added in v0.2.1

func ShowPortfolio(ctx context.Context, cmd *cli.Command) error

ShowPortfolio shows details about a portfolio.

func UpdateAllQuotes added in v0.2.1

func UpdateAllQuotes(ctx context.Context, cmd *cli.Command) error

UpdateAllQuotes triggers an update of all quotes.

func UpdateQuote added in v0.2.1

func UpdateQuote(ctx context.Context, cmd *cli.Command) error

UpdateQuote triggers an update of one or more securities' quotes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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