cliutil

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2020 License: MIT Imports: 1 Imported by: 23

Documentation

Overview

Package cliutil provides some util functions for CLI

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentShell

func CurrentShell(onlyName bool) (path string)

CurrentShell get current used shell env file. eg "/bin/zsh" "/bin/bash"

func ExecCmd

func ExecCmd(binName string, args []string, workDir ...string) (string, error)

ExecCmd a CLI bin file and return output. Usage:

ExecCmd("ls", []string{"-al"})

func ExecCommand

func ExecCommand(binName string, args []string, workDir ...string) (string, error)

ExecCommand alias of the ExecCmd()

func HasShellEnv

func HasShellEnv(shell string) bool

HasShellEnv has shell env check. Usage:

HasShellEnv("sh")
HasShellEnv("bash")

func QuickExec added in v0.1.4

func QuickExec(cmdLine string, workDir ...string) (string, error)

QuickExec quick exec an simple command line

func ShellExec

func ShellExec(cmdLine string, shells ...string) (string, error)

ShellExec exec command by shell cmdStr eg. "ls -al"

Types

This section is empty.

Jump to

Keyboard shortcuts

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