Skip to content

module providing golang functions/building blocks for the use in command line interfaces

License

Notifications You must be signed in to change notification settings

stuttgart-things/sthingsCli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stuttgart-things/sthingsCli

providing golang building blocks for the use in command line interface modules

MODULES

TABLES

PRINT MULTIPLE TABLES w/ FUNC
#import (
#	"github.com/jedib0t/go-pretty/v6/table"
# 	"sthingsCli "github.com/stuttgart-things/sthingsCli"
#)

PrintTable(table.Row{"SEVERITY", "SYSTEM", "TAGS", "ARTIFACTS"}, table.Row{message.Severity, message.System, message.Tags, message.Artifacts}, table.StyleColoredBlackOnBlueWhite)

func PrintTable(header, row table.Row, style table.Style) {

	t := table.NewWriter()
	t.SetOutputMirror(os.Stdout)
	t.AppendHeader(header)
	t.AppendRow(row)
	t.SetStyle(style)
	t.Render()
}
PRINT STRUCT OBJECT AS TABLE
#import (
#	"github.com/jedib0t/go-pretty/v6/table"
# 	"sthingsCli "github.com/stuttgart-things/sthingsCli"
#)

tw := table.NewWriter()
tw.AppendHeader(sthingsCli.CreateTableHeader(message))
tw.AppendRow(sthingsCli.CreateTableRows(message))

tw.SetOutputMirror(os.Stdout)
tw.SetStyle(table.StyleColoredBright)
tw.Render()
PRINT CUSTOM TABLE
#import (
#	"github.com/jedib0t/go-pretty/v6/table"
#)

tw1 := table.NewWriter()
tw1.AppendHeader(table.Row{"SEVERITY", "SYSTEM", "TAGS", "ARTIFACTS"})
tw1.AppendRow([]interface{}{message.Severity, message.System, message.Tags, message.Artifacts})
tw1.SetOutputMirror(os.Stdout)
tw1.SetStyle(table.StyleColoredBlackOnBlueWhite)
tw1.Render()

GIT

CLONE GIT REPOSITORY, GET FILE LIST + READ FILE
gitRepository         := "https://github.com/stuttgart-things/kaeffken.git"
gitBranch             := "main"
gitCommitID           := "09de9ff7b5c76aff8bb32f68cfb0bbe49cd5a7a8"

repo, cloneStatus := sthingsCli.CloneGitRepository(gitRepository, gitBranch, gitCommitID, nil)

if cloneStatus {
    fileList, directoryList = sthingsCli.GetFileListFromGitRepository("", repo)
    fmt.Println(fileList, directoryList)
}

readMe := sthingsCli.ReadFileContentFromGitRepo(repo, "README.md")
fmt.Println(readMe)

TASKFILE

task: Available tasks for this project:
* lint:       Lint code
* tag:        commit, push & tag the module
* test:       Test code

LICENSE

APACHE 2.0

Copyright 2023 patrick hermann.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Author Information

Patrick Hermann, stuttgart-things 04/2023

About

module providing golang functions/building blocks for the use in command line interfaces

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages