GithubHelp home page GithubHelp logo

tau-cli's Introduction

Tau CLI
Tau CLI

Local Coding Equals Global Production

Release License Go Report Card GoDoc Discord

tau is a command-line interface (CLI) tool for interacting with Taubyte-based Clouds. It enables users to create, manage projects, applications, resources, and more directly from the terminal.

Installation

NPM

npm i @taubyte/cli

Self extracting

curl https://get.tau.link/cli | sh

Fetch and Install with Go

go install github.com/taubyte/tau-cli@latest

You can rename tau-cli to tau or create an alias.

Clone and Build

git clone https://github.com/taubyte/tau-cli
cd tau
go build -o ~/go/bin/tau

Offline version (Optional)

Fails faster if exploring an unregistered project

go build -o ~/go/bin/otau -tags=localAuthClient

Login

tau login - opens selection with default already selected - simply logs in if only default available - will open new if no profiles found tau login --new for new

  • --set-default for making this new auth the default tau login <profile-name> for using a specific profile

Environment Variables:

  • TAUBYTE_PROJECT Selected project
  • TAUBYTE_PROFILE Selected profile
  • TAUBYTE_APPLICATION Selected application
  • TAUBYTE_CONFIG (default: ~/tau.yaml) Config location
  • TAUBYTE_SESSION (default: /tmp/tau-<shell-pid>) Session location
  • DREAM_BINARY (default: $GOPATH/dream) Dream binary location

Testing

All tests

go test -v ./...

Hot reload tests

$ cd tests

Edit air config cmd = "go test -v --run <Function|Database|...> [-tags=no_rebuild]

(Optional) Add debug: true, to an individual test

$ air

Running Individual Prompts

go run ./prompts/internal

Measuring Coverage:

Calculate coverage for all packages

go test -v ./... -tags=localAuthClient,projectCreateable,localPatrick,cover,noPrompt -coverprofile cover.out -coverpkg ./...

Display coverage for all packages

go tool cover -html=cover.out
go tool cover -func=cover.out

Documentation

For documentation head to tau.how

tau-cli's People

Contributors

skelouse avatar tafseer-khan avatar samyfodil avatar arontaubyte avatar taubyte0 avatar

Stargazers

Jeff Bouchard avatar esteban avatar Erick Heredia avatar  avatar Dev avatar  avatar Alphonse Ngandjui avatar Nicholas Guerrero avatar Katherine avatar  avatar Dennis Balan avatar Jared Horvat avatar  avatar Yifei Ning avatar Quinn Millican avatar  avatar  avatar  avatar Kevin Baker avatar Jacob Melosi avatar  avatar Lucy Conner avatar Amandagifford101 avatar v1rtl avatar terrifictable avatar

Watchers

Lucian avatar  avatar

tau-cli's Issues

Custom Start Commands

Is there support for custom start functions in the tau/cli/app/app.go ? Wherein I script starting the app with custom config (not just with CLI, directly in go)?

Incorrect handling of nested subcommands and command name removal

Issue Description:

In cli/args/args.go, The current implementation of the code does not correctly handle nested subcommands and fails to remove the command name from the arguments, leading to potential issues in command parsing. This issue aims to address these problems and improve the overall code quality.

Steps to Reproduce:

  1. Create a scenario with nested subcommands, where you have multiple levels of subcommands.
  2. Execute commands that involve nested subcommands and observe the behavior.

Expected Behavior:

  1. Nested subcommands should be handled correctly, with the command name removed from the arguments.
  2. The sequence of parsing subcommands and processing arguments should be correct.

Actual Behavior:

  1. Nested subcommands are not handled correctly.
  2. The command name is not removed from the arguments, leading to incorrect parsing.

Proposed Changes:

  • Update the parseCommandArguments function to use the new helper function for finding the index of a command or its alias in the arguments.
  • Revise the MovePostFixCommands function to correctly handle nested subcommands and ensure the command name is removed from the arguments.

In a very rough draft, not intended to be perfect, here is how I believe parseCommandArguments() could be improved:

func parseCommandArguments(commands []*cli.Command, args ...string) []string {
    if len(args) <= 1 || len(commands) == 0 {
        return args
    }

    // Helper function to find the index of a command or its alias in args
    findCommandIndex := func(cmd *cli.Command) int {
        for _, name := range append([]string{cmd.Name}, cmd.Aliases...) {
            idx := IndexOf(args, name)
            if idx != -1 {
                return idx
            }
        }
        return -1
    }

    // Iterate through commands
    for _, cmd := range commands {
        idx := findCommandIndex(cmd)

        if idx != -1 {
            // Parse command flags and arguments
            cmdArgs := append([]string{cmd.Name}, args[idx+1:]...)
            cmdArgs = append(cmdArgs, MovePostFixCommands(args[:idx], cmd.Subcommands)...)
            args = cmdArgs

            return args
        }
    }

    return args
}

and below is how I believe, on a very rough level, again, not intended to be perfect, how we would potentially improve MovePostFixCommands():

// MovePostFixCommands places the command being called at the beginning of the args slice for parsing
func MovePostFixCommands(args []string, commands []*cli.Command) []string {
    cmdArgs := []string{}
    cmdName := ""

    // Find which command is being called
    for _, cmd := range commands {
        argName := cmd.Name
        idx := IndexOf(args, argName)
        if idx == -1 {
            for _, alias := range cmd.Aliases {
                idx = IndexOf(args, alias)
                if idx != -1 {
                    argName = alias
                    break
                }
            }
        }
        if idx != -1 {
            // Set the command name
            cmdName = argName

            // Remove argName from args
            args = append(args[:idx], args[idx+1:]...)

            // Recursively handle subcommands
            args = MovePostFixCommands(args, cmd.Subcommands)
            break
        }
    }

    if cmdName != "" {
        cmdArgs = append(cmdArgs, cmdName)
    }

    return append(cmdArgs, args...)
}

Obviously, this is just a rough draft, and I'm sure there are better ways to implement this. I'm also not sure if this is the best way to handle nested subcommands, but I believe it is a step in the right direction.

Additionally, the ParseArguments() function would remain unchanged.

tau delete project prompt is misleading

Removing project `{name}` will unregister the following repositories:
- name1
- name2

then to unregister resources prompt asks:

Remove Resources?
- [ ] resource 1
- [ ] resource 2

Remove (none) selection

There are multiple prompt selections where (none) is an option. Does not make sense to have this

Clean up suggestions

Overall, it seems fine, but there are a few minor suggestions and potential improvements:

  1. Consider adding comments to your components and functions. It will not only make code easier to read for other but also for your team.
  2. I've noticed a lot of files named the same. This can lead to confusion when navigation from one file to another withindifferent folders.
  3. I would suggest organize code folders by logic. Because at first glance they seem to be hard to understand the purpose of them

If you have any question or comments, please let me know, I'm always open to collaborate

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.