util

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Examples

Constants

View Source

Logo format of SGI.

Variables

View Source
var (
	// Path to Working directory related to CLI tools.
	// The path is described relative to the HOME directory.
	CliDir = ".sgi"

	// Name of the file where the account information is stored.
	AccountFile = "account.json"
)

Functions

func PrintLogo()

Print the large logo of this cli tool. The logo consists of the Sakamichi-mark and this cli name(SGI). The format is defined at CLI_LOGO.

This function uses dimiron1/banner package. To get detailed information, please see: https://github.com/dimiro1/banner

func PrintTable

func PrintTable(header []string, data [][]string) error
Example
package main

import (
	"github.com/android-project-46group/sgi-cli/util"
)

func main() {
	var header []string
	var data [][]string
	header = []string{
		"id",
		"name",
	}
	data = append(data, []string{
		"1",
		"John",
	})
	data = append(data, []string{
		"2",
		"Doe",
	})
	util.PrintTable(header, data)

}
Output:

+----+------+
| ID | NAME |
+----+------+
|  1 | John |
|  2 | Doe  |
+----+------+

Types

type Account

type Account struct {

	// BaseURL is the entrypoint of the api.
	BaseURL string

	// APIKey is needed to get information using API call
	APIKey string
}

Account contains the settings for api.

type Config

type Config struct {

	// Version is the application version.
	// Basically it consists of version and git-revision.
	Version string

	// Account contains the api settings of this cli
	Account Account
}

Config contains the all settings for this cli. Create an instance of Config, by using NewConfig()

func NewConfig

func NewConfig(version string) (Config, error)

NewConfig returns a new Config instance. The configuration value is obtained from AccountFile under the ${HOME} directory. You need to pass the cli version as an argument.

Jump to

Keyboard shortcuts

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