Marshal data into commands struct!

Overview

Commandarrgh in a nuthsell

Commandarrgh is an interface that helps you marshaling data into a command arguments structure. Maybe you have been trying to use others cli frameworks to make this task without any effect because all of them are based on the user input.

How to use it

Commandarrgh is easy to use, you only need to define the struct in which the data will be marshaled to by using commandarrgh tags:

type CommandTransferFilesArgs struct {
    Dst `flag:"-dst" helptext:"file's directory" binding:"required" validators:"stat-path"`
    Src `flag:"-src" helptext:"file's directory" binding:"required" validators:"stat-path"`
    AlsoGetHiddens `flag:"-h" helptext:"include hidden folder's files" binding:"bool" default:"false" `
}

Method Marshal will fill the struct with the string data as the following example shows:

args := &CommandTransferFilesArgs{}
data := "-dst ./memes/dog_bonks -src /downloaded_memes/dog_bonks -h"

err := commandarrgh.Marshal(data, args)
...

A full example of how to use commandarrgh:

package main

import github.com/alvarogf97/commandarrgh

const (
    COMMAND_TRANSFER_FILES = "transfer"
)

type CommandTransferFilesArgs struct {
    Dst `flag:"-dst" helptext:"file's directory" binding:"required" validators:"stat-path"`
    Src `flag:"-src" helptext:"file's directory" binding:"required" validators:"stat-path"`
    AlsoGetHiddens `flag:"-h" helptext:"include hidden folder's files" binding:"bool" default:"false" `
}

func handleTransferFilesCommand(args CommandTransferFilesArgs){
    // handle here your command :D
    ...
}

func main(){
    data := "transfer -dst ./memes/dog_bonks -src /downloaded_memes/dog_bonks -h"
    cmd, cmdargs := commandarrgh.SplitCommand(data)

    switch cmd{
        case COMMAND_TRANSFER_FILES:
            args := &CommandTransferFilesArgs{}
            err := commandarrgh.Marshal(cmdargs, args)
            if err != nil {
                panic(err)
            }
            handleTransferFilesCommand(args)
        default:
            panic(fmt.Sprintf("No command handler found for `%s`", cmd))
    }
}

Validators

Commandarrgh helps you with data validation and trasnformation by using validators which are functions that gives the original value and returns the modified one or error in case the validation goes wrong. The following validators are available:

Name Function
path verifies the given value is a wellformed path, trasnform it to an absolute one and make it compatible with all os
stat-path makes the same function that path but it must be exists in the system

If someones need another validatios, please write an issure or a pull request and I will work to make it real

Releases(v0.0.1)
Owner
alvaro garcia fernandez
Software engineering.
alvaro garcia fernandez
structslop is a static analyzer for Go that recommends struct field rearrangements to provide for maximum space/allocation efficiency.

structslop Package structslop defines an Analyzer that checks struct can be re-arranged fields to get optimal struct size.

orijtech 644 May 19, 2022
containedctx detects is a linter that detects struct contained context.Context field

containedctx containedctx detects is a linter that detects struct contained context.Context field Instruction go install github.com/sivchari/contained

sivchari 8 Mar 3, 2022
Visualise Go program GC trace data in real time

This project is no longer maintained I'm sorry but I do not have the bandwidth to maintain this tool. Please do not send issues or PRs. Thank you. gcv

Dave Cheney 1.1k May 18, 2022
This static analysis tool works to ensure your program's data flow does not spill beyond its banks.

Go Flow Levee This static analysis tool works to ensure your program's data flow does not spill beyond its banks. An input program's data flow is expl

Google 119 May 13, 2022
Drone Plugin for detecting credentials or other sensitive data in your repository

A plugin to detect hard-coded secrets and sensitive data in your source code files. Building Build the plugin binary: scripts/build.sh Build the plug

Drone by Harness 1 Apr 21, 2022
☄ The golang convenient converter supports Database to Struct, SQL to Struct, and JSON to Struct.

Gormat - Cross platform gopher tool The golang convenient converter supports Database to Struct, SQL to Struct, and JSON to Struct. 中文说明 Features Data

永林 268 May 6, 2022
Parametrized JSON logging library in Golang which lets you obfuscate sensitive data and marshal any kind of content.

Noodlog Summary Noodlog is a Golang JSON parametrized and highly configurable logging library. It allows you to: print go structs as JSON messages; pr

Gyoza Tech 37 Apr 19, 2022
Match regex group into go struct using struct tags and automatic parsing

regroup Simple library to match regex expression named groups into go struct using struct tags and automatic parsing Installing go get github.com/oris

Ori Seri 108 May 5, 2022
A better way to marshal and unmarshal YAML in Golang

YAML marshaling and unmarshaling support for Go Introduction A wrapper around go-yaml designed to enable a better way of handling YAML when marshaling

Sam Ghods 901 May 15, 2022
Go package that adds marshal and unmarshal features to nullable sql types.

#Nullable Very simple Go module to handle nullable fields. Basically, it adds to sql package types the JSON marshal and unmarshal features. It has 100

Diego Hordi 1 Jan 20, 2022
atomic time package with json Marshal / Unmarshal support

ATime Atomic Time package for Go, optimized for performance yet simple to use. Usage // one line create dt := atime.New() // allocates *AtomicTime dt

Jakub Wosyka 0 Feb 6, 2022
painless task queue manager for shell commands with an intuitive cli interface (execute shell commands in distributed cloud-native queue manager).

EXEQ DOCS STILL IN PROGRESS. Execute shell commands in queues via cli or http interface. Features Simple intuitive tiny cli app. Modular queue backend

Mohammed Al Ashaal 12 Jan 29, 2022
Go package exposing a simple interface for executing commands, enabling easy mocking and wrapping of executed commands.

go-runner Go package exposing a simple interface for executing commands, enabling easy mocking and wrapping of executed commands. The Runner interface

Krystal 4 May 11, 2022
Console - Commands are defined in struct extending pkg/command/create user.go

Console Creating a Command Commands are defined in struct extending pkg/command/

null 0 Jan 2, 2022
goconfig uses a struct as input and populates the fields of this struct with parameters from command line, environment variables and configuration file.

goconfig goconfig uses a struct as input and populates the fields of this struct with parameters from command line, environment variables and configur

Go Sidekick 155 Apr 23, 2022
Pagser is a simple, extensible, configurable parse and deserialize html page to struct based on goquery and struct tags for golang crawler

Pagser Pagser inspired by page parser。 Pagser is a simple, extensible, configurable parse and deserialize html page to struct based on goquery and str

foolin 60 May 8, 2022
:100:Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving

Package validator Package validator implements value validations for structs and individual fields based on tags. It has the following unique features

Go Playgound 10.4k May 16, 2022
Copier for golang, copy value from struct to struct and more

Copier I am a copier, I copy everything from one to another Features Copy from field to field with same name Copy from method to field with same name

Jinzhu 3k May 11, 2022
💯 Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving

Package validator implements value validations for structs and individual fields based on tags.

Flamego 12 Feb 16, 2022
Go generator to copy values from type to type and fields from struct to struct. Copier without reflection.

Copygen is a command-line code generator that generates type-to-type and field-to-field struct code without adding any reflection or dependenc

SwitchUpCB 121 May 15, 2022
Prometheus Common Data Exporter can parse JSON, XML, yaml or other format data from various sources (such as HTTP response message, local file, TCP response message and UDP response message) into Prometheus metric data.

Prometheus Common Data Exporter Prometheus Common Data Exporter 用于将多种来源(如http响应报文、本地文件、TCP响应报文、UDP响应报文)的Json、xml、yaml或其它格式的数据,解析为Prometheus metric数据。

null 6 Apr 20, 2022
Gookit 550 May 17, 2022
Turn shell commands into web services

webify Turn functions and commands into web services For a real world example, see turning a Python function into a web service. Overview webify is a

Michael Alexander 901 May 12, 2022
Brigodier is a command parser & dispatcher, designed and developed for command lines such as for Discord bots or Minecraft chat commands. It is a complete port from Mojang's "brigadier" into Go.

brigodier Brigodier is a command parser & dispatcher, designed and developed to provide a simple and flexible command framework. It can be used in man

Minekube 15 Apr 22, 2022
webify - Turn functions and commands into web services

webify is a very basic CGI server which forwards all requests to a single script. A design goal is to be as zero-config as possible.

Michael Alexander 903 May 16, 2022
Load configuration in cascade from multiple backends into a struct

Confita is a library that loads configuration from multiple backends and stores it in a struct. Supported backends Environment variables JSON files Ya

Heetch 442 May 11, 2022
a package for decode form's values into struct in Go

formam A Go package to decode HTTP form and query parameters. The only requirement is Go 1.10 or later. Features Infinite nesting for maps, structs an

Monoculum 169 Apr 2, 2022
Transmo - Transform Model into another model based on struct for Go (Golang).

Transmo Transmo is a Go library for transform model into another model base on struct. This library detect your field name to copy that into another m

Reza Ramadhan Irianto 0 Jan 7, 2022
GC2 is a Command and Control application that allows an attacker to execute commands on the target machine using Google Sheet and exfiltrate data using Google Drive.

GC2 GC2 (Google Command and Control) is a Command and Control application that allows an attacker to execute commands on the target machine using Goog

Lorenzo Grazian 140 May 9, 2022