Some cleanup and comments.

This commit is contained in:
Matthew Hooker 2018-04-12 11:34:21 -07:00
parent 4e2f14196a
commit 1c0af28662
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1
5 changed files with 628 additions and 235 deletions

View File

@ -147,7 +147,6 @@ func (s *StepTypeBootCommand) Run(ctx context.Context, state multistep.StateBag)
ui.Error(err.Error()) ui.Error(err.Error())
return multistep.ActionHalt return multistep.ActionHalt
} }
} }
return multistep.ActionContinue return multistep.ActionContinue

File diff suppressed because it is too large Load Diff

View File

@ -1,21 +1,6 @@
{ {
package bootcommand package bootcommand
/*
func main() {
in := "<wait><wait10><wait1s><wait1m2ns>"
in += "foo/bar > one"
in += "<fOn> b<fOff>"
in += "<f3><f12><spacebar><leftalt><rightshift><rightsuper>"
got, err := ParseReader("", strings.NewReader(in))
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s\n", got)
}
*/
} }
Input <- expr:Expr EOF { Input <- expr:Expr EOF {
@ -45,11 +30,9 @@ CharToggle = ExprStart lit:(Literal) t:(On / Off) ExprEnd {
Special = ExprStart s:(SpecialKey) t:(On / Off)? ExprEnd { Special = ExprStart s:(SpecialKey) t:(On / Off)? ExprEnd {
if t == nil { if t == nil {
//return fmt.Sprintf("S(%s)", s), nil
return &specialExpression{string(s.([]byte)), KeyPress}, nil return &specialExpression{string(s.([]byte)), KeyPress}, nil
} }
return &specialExpression{string(s.([]byte)), t.(KeyAction)}, nil return &specialExpression{string(s.([]byte)), t.(KeyAction)}, nil
//return fmt.Sprintf("S%s(%s)", t, s), nil
} }
Number = '-'? Integer ( '.' Digit+ )? { Number = '-'? Integer ( '.' Digit+ )? {

View File

@ -12,14 +12,15 @@ import (
TODO: TODO:
* tests * tests
* comments * comments
* lower-case specials
* check that `<del>` works on parallels. It's different now.
*/ */
// Keys actions can take 3 states // KeysAction represents what we want to do with a key press.
// we either want to // It can take 3 states. We either want to:
// * press the key once // * press the key once
// * press and hold // * press and hold
// * press and release // * press and release
type KeyAction int type KeyAction int
const ( const (
@ -70,6 +71,8 @@ func (s expressionSequence) Do(ctx context.Context, b BCDriver) error {
return nil return nil
} }
// GenerateExpressionSequence generates a sequence of expressions from the
// given command.
func GenerateExpressionSequence(command string) (expressionSequence, error) { func GenerateExpressionSequence(command string) (expressionSequence, error) {
got, err := ParseReader("", strings.NewReader(command)) got, err := ParseReader("", strings.NewReader(command))
if err != nil { if err != nil {

View File

@ -17,7 +17,7 @@ func TestParse(t *testing.T) {
in := "<wait><wait20><wait3s><wait4m2ns>" in := "<wait><wait20><wait3s><wait4m2ns>"
in += "foo/bar > one 界" in += "foo/bar > one 界"
in += "<fOn> b<fOff>" in += "<fOn> b<fOff>"
in += "<f3><f12><spacebar><leftalt><rightshift><rightsuper>" in += "<foo><f3><f12><spacebar><leftalt><rightshift><rightsuper>"
got, err := ParseReader("", strings.NewReader(in)) got, err := ParseReader("", strings.NewReader(in))
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)