Example #1
0
File: file.go Project: calj/kaigara
func CreateDir(dirname string) {
	if Exists(dirname) {
		term.Error("directory '" + dirname + "' already exists")
	} else {
		err := os.Mkdir(dirname, 0755)

		if err != nil {
			term.Error(err.Error())
		} else {
			term.Create(dirname)
		}
	}
}
Example #2
0
File: file.go Project: calj/kaigara
func CreateFile(filename string) {
	if Exists(filename) {
		term.Error("file '" + filename + "' already exists")
	} else {
		file, err := os.Create(filename)

		if err != nil {
			term.Error(err.Error())
		} else {
			term.Create(filename)
		}

		defer file.Close()
	}
}
Example #3
0
File: file.go Project: calj/kaigara
func Read(filename string) string {
	file, err := ioutil.ReadFile(filename)
	if err != nil {
		term.Error(err.Error())
	}

	return string(file)
}
Example #4
0
File: exec.go Project: calj/kaigara
//
//     http://www.apache.org/licenses/LICENSE-2.0

package cmd

import (
	"github.com/mod/kaigara/pkg/operation"
	"github.com/mod/kaigara/pkg/term"
	"github.com/spf13/cobra"
)

// execCmd represents the exec command
var execCmd = &cobra.Command{
	Use:   "exec PROGRAM",
	Short: "Execute an executable in a child process",
	Long: `This command can be used as an entrypoint, it will
search in $PATH for the executable and run it in a child
process`,
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) > 0 {
			operation.Execute(args[0], args[1:])
		} else {
			term.Error("Missing application to exec")
		}
	},
}

func init() {
	RootCmd.AddCommand(execCmd)
}
Example #5
0
File: file.go Project: calj/kaigara
func Write(filename string, data string) {
	err := ioutil.WriteFile(filename, []byte(data), 0644)
	if err != nil {
		term.Error(err.Error())
	}
}