id

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package id List is responsible for id List managing

Index

Constants

This section is empty.

Variables

View Source
var (
	// Verbose gives mor information on output if set. The value is injected from main packages.
	Verbose bool

	// DryRun if set, inhibits real changes
	DryRun bool

	// FnJSON is the filename for the JSON formatted ID list.
	FnJSON string
)

Functions

func ConditionalFilePath added in v0.10.0

func ConditionalFilePath(fn string) string

ConditionalFilePath returns absolute file path if fn is not "off" or "none".

func ScUpdate

func ScUpdate(fnJSON string) error

ScUpdate is subcommand update

func ScZero

func ScZero(SrcZ string, cmd *flag.FlagSet) error

ScZero does replace all ID's in sourc tree with 0

func ZeroSourceTreeIds added in v0.10.0

func ZeroSourceTreeIds(srcRoot string, run bool)

ZeroSourceTreeIds is overwriting with 0 all id's from source code tree srcRoot. It does not touch idlist.

Types

type ArrayFlag added in v0.10.0

type ArrayFlag []string

ArrayFlag is a slice type for multi flag

var (
	// Srcs gets multiple files or directories.
	Srcs ArrayFlag
)

func (*ArrayFlag) Set added in v0.10.0

func (i *ArrayFlag) Set(value string) error

Set is a needed method for multi flags.

func (*ArrayFlag) String added in v0.10.0

func (i *ArrayFlag) String() string

String method is the needed for interface satisfaction.

type Item

type Item struct {
	ID      int    `json:"id"`      // identifier
	FmtType string `json:"fmtType"` // format type (bitsize and number of fmt string parameters)
	FmtStrg string `json:"fmtStrg"` // format string
	Created int32  `json:"created"` // utc unix time of creation
	Removed int32  `json:"removed"` // utc unix time of disappearing in processed src directory
}

Item is the basic element

type List

type List struct {
	// FnJSON is the filename of the id List
	FnJSON string

	// ItemList is a slice type containing the ID ItemList.
	ItemList []Item
}

List is the trice ID List

func New added in v0.10.0

func New() (l *List)

New returns a pointer to a list struct which stays up-to-date in case the til.json file changes.

func NewList added in v0.10.0

func NewList(fnJSON string) *List

NewList creates an ID List instance

func (*List) ExtendIDList added in v0.10.0

func (p *List) ExtendIDList(id int, typ, fmts string, verbose bool) (int, bool)

ExtendIDList returns id beause it could get changed when id is in List with different typ or fmts. It is an exported function for simplyfing tests in other packets.

func (*List) FileWatcher added in v0.10.0

func (p *List) FileWatcher()

FileWatcher checks id List file for changes taken from https://medium.com/@skdomino/watch-this-file-watching-in-go-5b5a247cf71f

func (*List) Index added in v0.10.0

func (p *List) Index(id int) int

Index returns the index of id inside p.List. If id is not found it returns -1.

func (*List) Item added in v0.10.0

func (p *List) Item(index int) Item

Item returns the trice item on index from the List

func (*List) ReadListFile added in v0.10.0

func (p *List) ReadListFile()

ReadListFile reads idlist file in internal struct and starts a file watcher.

Just in case the idlist file gets updated, the file watcher updates the internals struct. This way trice needs not to be restarted during development process.

func (*List) Update added in v0.10.0

func (p *List) Update(root string, run, verbose bool) error

Update is parsing source tree root and performing these actions: - replace FmtType( Id(0), ...) with FmtType( Id(n), ...) - find duplicate FmtType( Id(n), ...) and replace one of them if trices are not identical - extend file fnIDList

func (*List) WriteListFile added in v0.10.0

func (p *List) WriteListFile()

WriteListFile marshalls p.List to p.fnJSON.

func (*List) ZeroTimestampCreated added in v0.10.0

func (p *List) ZeroTimestampCreated()

ZeroTimestampCreated sets all timstamps 'created' to 0.

Jump to

Keyboard shortcuts

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