emul

package
v0.0.0-...-1b113c7 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Example (Parse)
package main

import (
	"fmt"

	"github.com/KusoKaihatsuSha/tray_helper/internal/emul"
)

func main() {

	text01 := `c:\Users\user\Downloads\tempApp\some.exe`
	text02 := `"c:\Users\user\Downloads\temp App\some.exe"`
	text03 := `echo -e "Hello world\n\tfrom golang"`
	text04 := `ping -n 10 ya.ru`
	text05 := `cmd.exe /k "c:\Users\user\Downloads\temp App\some.exe"`
	text06 := `ssh -i ~/.ssh/dops test@127.0.0.1`

	for _, val := range emul.ParseCommandCmd(text01) {
		fmt.Printf("%s\n", val)
	}
	for _, val := range emul.ParseCommandCmd(text02) {
		fmt.Printf("%s\n", val)
	}
	for _, val := range emul.ParseCommandCmd(text03) {
		fmt.Printf("%s\n", val)
	}
	for _, val := range emul.ParseCommandCmd(text04) {
		fmt.Printf("%s\n", val)
	}
	for _, val := range emul.ParseCommandCmd(text05) {
		fmt.Printf("%s\n", val)
	}
	for _, val := range emul.ParseCommandCmd(text06) {
		fmt.Printf("%s\n", val)
	}

}
Output:

c:\Users\user\Downloads\tempApp\some.exe
c:\Users\user\Downloads\temp App\some.exe
echo
-e
Hello world\n\tfrom golang
ping
-n
10
ya.ru
cmd.exe
/k
c:\Users\user\Downloads\temp App\some.exe
ssh
-i
~/.ssh/dops
test@127.0.0.1
Example (ParseCommands)
package main

import (
	"fmt"

	"github.com/KusoKaihatsuSha/tray_helper/internal/emul"
)

func main() {
	tmp := emul.ParseCommands("TARGET@Notepad|GEN@-16|SLEEP@300ms|PRESS@CTRL+V|SLEEP@300ms|PRESS@ENTER|PRINT@||SLEEP@300ms|EXECSTD@ping google.com|SLEEP@300ms|PRESS@CTRL+V|SLEEP@300ms|CLIP@test|cmd \\k C:\\Program Files\\totalcmd\\TOTALCMD64.EXE")

	for _, val := range tmp {
		fmt.Printf("| action: %s, data: %s |\n", val.Name, val.Data)
	}

}
Output:

| action: TARGET, data: Notepad |
| action: GEN, data: -16 |
| action: SLEEP, data: 300ms |
| action: PRESS, data: CTRL+V |
| action: SLEEP, data: 300ms |
| action: PRESS, data: ENTER |
| action: PRINT, data:  |
| action: SLEEP, data: 300ms |
| action: EXECSTD, data: ping google.com |
| action: SLEEP, data: 300ms |
| action: PRESS, data: CTRL+V |
| action: SLEEP, data: 300ms |
| action: CLIP, data: test |
| action: cmd \k C:\Program Files\totalcmd\TOTALCMD64.EXE, data:  |

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handle

func Handle(ctx context.Context, cancel context.CancelFunc, texts string, repeat int) int

Handle - handler the command

func ParseCommand

func ParseCommand(cmd string, s ...rune) []string

ParseCommand parse one command into struct

func ParseCommandCmd

func ParseCommandCmd(cmd string) []string

Types

type Command

type Command struct {
	Name string
	Data string
}

Command consist name and data of one command

func ParseCommands

func ParseCommands(cmd string) []Command

ParseCommands parse all actions line

type CtxKey

type CtxKey string

CtxKey wrapper around context keys

Jump to

Keyboard shortcuts

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