app

package
v0.0.0-...-db335bc Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2021 License: MIT Imports: 11 Imported by: 0

README

app

-- import "."

The app package is holding logic for coordinating the features of the app itself. Holding its configuration too. It's faily isolated from the logic of doing the actual communication (part of the todoapi package). The app package aims to be the link between the commands in cmd and the communication results provided from the todoapi.

Usage

var CfgFilePath string
var ColumnsToKeysMap map[string]string = map[string]string{
	"display name": "Name",
	"shared":       "Shared",
	"owner":        "Owner",
	"system name":  "System",
	"id":           "Id",
}

Maps the column values returned from the MS API to the ones we need to display in the CLI.

var ListItemHeaders []string = func(m map[string]string) []string {
	keys := []string{}

	for k := range m {
		keys = append(keys, k)
	}

	return keys
}(ColumnsToKeysMap)

Constructs a list of strings representing the needed headers for the table thats printed as a result of the List operations.

func InitAppConfig
func InitAppConfig()

This is app's entry point. It's being invoked by the command-line tool that is being used. Here we read the config file from the path that's being set for it and initializing the configuration for the app.

func ListsCreate
func ListsCreate(name string, columns []string) error

Creates a new list item and prints it back to output, formatted with the list of columns mentioned in the columns []string.

func ListsIndex
func ListsIndex(columns []string) error

Prints a formatted table with all the lists, contains only the columns, listed in the columns []string.

func ListsUpdate
func ListsUpdate(id, name string, columns []string) error

Updates the name of a list. Upon success it returns the updated list with its attributes in columns to the CLI. TODO: Extend the update posibilities to other attributes too (e.g. set as a default list)

func Login
func Login()

Facilitates the login procedure for the app. Mainly - reads credentials from the config file and saves them in a place they can be easily accessed.

func LoginNeeded
func LoginNeeded() bool

Checks if the user needs to be logged in (again) or his current session is still active.

Documentation

Overview

The `app` package is holding logic for coordinating the features of the app itself. Holding its configuration too. It's faily isolated from the logic of doing the actual communication (part of the `todoapi` package). The `app` package aims to be the link between the commands in `cmd` and the communication results provided from the `todoapi`.

Index

Constants

This section is empty.

Variables

View Source
var CfgFilePath string
View Source
var ColumnsToKeysMap map[string]string = map[string]string{
	"display name": "Name",
	"shared":       "Shared",
	"owner":        "Owner",
	"system name":  "System",
	"id":           "Id",
}

Maps the column values returned from the MS API to the ones we need to display in the CLI.

View Source
var ListItemHeaders []string = func(m map[string]string) []string {
	keys := []string{}

	for k := range m {
		keys = append(keys, k)
	}

	return keys
}(ColumnsToKeysMap)

Constructs a list of strings representing the needed headers for the table thats printed as a result of the List operations.

Functions

func InitAppConfig

func InitAppConfig()

This is app's entry point. It's being invoked by the command-line tool that is being used. Here we read the config file from the path that's being set for it and initializing the configuration for the app.

func ListsCreate

func ListsCreate(name string, columns []string) error

Creates a new list item and prints it back to output, formatted with the list of columns mentioned in the `columns []string`.

func ListsIndex

func ListsIndex(columns []string) error

Prints a formatted table with all the lists, contains only the columns, listed in the `columns []string`.

func ListsUpdate

func ListsUpdate(id, name string, columns []string) error

Updates the name of a list. Upon success it returns the updated list with its attributes in columns to the CLI. TODO: Extend the update posibilities to other attributes too (e.g. set as a default list)

func Login

func Login()

Facilitates the login procedure for the app. Mainly - reads credentials from the config file and saves them in a place they can be easily accessed.

func LoginNeeded

func LoginNeeded() bool

Checks if the user needs to be logged in (again) or his current session is still active.

Types

This section is empty.

Jump to

Keyboard shortcuts

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