utils

package
v0.0.0-...-d2af1df Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

A set of utility functions to handle with user's github personal access token

The user's GitHub Personal Access Token could be stored in operating system keyring, environment var or claro's config file (default $HOME/.claro.env)

A set of utility functions to handle with GitHub REST API

A set of utility functions to handle with git command

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAndCommitGradeFile

func AddAndCommitGradeFile(filename, repositoryDir string, p *pterm.ProgressbarPrinter)

To add and commit a grade file in a GitHub repository

func CheckExternalsCommands

func CheckExternalsCommands()

func CloneRepositories

func CloneRepositories(outputDir string, repositories []RepData) ([]string, []string)

To clone repositories from GitHub

func CreateKey

func CreateKey(password string, removeIfExist bool) error

Store a user's github personal access token in operating system keyring

func DeletePasswordItem

func DeletePasswordItem() error

Delete user's github personal access token from operating system keyring

func GetAndSaveToken

func GetAndSaveToken(save bool) string

To get user's github personal access token

func GetPassword

func GetPassword() (string, error)

Get the user's github personal access token from operating system keyring

func PromptUser

func PromptUser(message string, question string) bool

A Yes/No prompt for user

func Pull

func Pull(files []fs.DirEntry, directory string)

To pull all GitHub repositories inside a specific local directory

func ReadTokenFromStdIn

func ReadTokenFromStdIn() string

Ask user about github personal access token

func SaveGHToken

func SaveGHToken(ghToken string)

Try to save the github personal access token: (1) os keyring; (2) claro config file

func WriteConfigFile

func WriteConfigFile(key, value, returnMessage string)

Write key/value in the config file

Types

type Config

type Config struct {
	CommitMessage string `mapstructure:"COMMIT_MESSAGE"`
	GradeFileName string `mapstructure:"GRADE_FILENAME"`
	GradeTitle    string `mapstructure:"GRADE_TITLE"`
	GradeString   string `mapstructure:"GRADE_STRING"`
	GHToken       string `mapstructure:"GH_TOKEN"`
}

Struct to store config file vars

func GetConf

func GetConf() *Config

user viper to read envvar and returns a Config struct

type RepData

type RepData struct {
	Name string
	Url  string
	Size uint64
}

func GetRepositoryList

func GetRepositoryList(org, rep string) []RepData

Get repository list from an organization that has a specific prefix

Jump to

Keyboard shortcuts

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