appinfo

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2022 License: MIT Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package appinfo はアプリの設定情報およびタスクを管理するオブジェクトを定義します。

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppInfo

type AppInfo struct {
	Config    *config.Config // アプリの設定ファイル情報
	Tasks     *todo.Set      // ローカルおよびグローバルのタスク情報
	Version   string         // アプリのバージョン情報
	IsVerbose bool           // アプリの詳細表示モード(情報がある場合)
}

AppInfo はアプリの設定および読み込んだタスクを保持する型です。

生成されたオブジェクトは、アプリの各コマンド(cmd にあるパッケージ)に共有情 報として渡されます。

func New

func New(pathDirCurr, pathDirHome, version string) (*AppInfo, error)

New は初期化された AppInfo オブジェクトを返します。

返されたオブジェクトは pathDirCurr, pathDirHome に存在したアプリの設定および タスクを読み込んだ状態で返されます。

Example
package main

import (
	"fmt"
	"log"
	"os"

	"github.com/Qithub-BOT/QiiTask/core/appinfo"
)

func main() {
	exitOnErr := func(err error) {
		if err != nil {
			log.Fatalln(err)
		}
	}

	// Empty args will set the default
	appInfo, err := appinfo.New("", "", "")
	exitOnErr(err)

	// Get expect path (as default path for local task)
	pathDirCurr, err := os.Getwd()
	exitOnErr(err)

	// Get expect path (as default path for global task)
	pathDirHome, err := os.UserHomeDir()
	exitOnErr(err)

	// Assertion
	if appInfo.Version == "" {
		fmt.Println("ok (app version whould be as is)")
	}

	if pathDirCurr == appInfo.Tasks.Local.Dir() {
		fmt.Println("ok")
	}

	if pathDirHome == appInfo.Tasks.Global.Dir() {
		fmt.Println("ok")
	}
}
Output:
ok (app version whould be as is)
ok
ok

Jump to

Keyboard shortcuts

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