Skip to content

Commit

Permalink
Change to skipPrompts and fix yaml parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben Restrepo committed Oct 19, 2023
1 parent d84a4dd commit 3ba24d4
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 60 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
skipenv: false
skipPrompts: false
---

```sh
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
skipenv: true
skipPrompts: true
---

```sh
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion internal/api/runme/parser/v1/parser.proto
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ message Cell {
message Frontmatter {
string shell = 1;
string cwd = 2;
bool skip_env = 3;
bool skip_prompts = 3;
}

message DeserializeRequest {
Expand Down
12 changes: 6 additions & 6 deletions internal/document/frontmatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
)

type Frontmatter struct {
Shell string
Cwd string
SkipEnv bool
Shell string
Cwd string
SkipPrompts bool `yaml:"skipPrompts,omitempty"`
}

type FrontmatterParseInfo struct {
Expand Down Expand Up @@ -69,8 +69,8 @@ func ParseFrontmatter(raw string) (f Frontmatter, info FrontmatterParseInfo) {

func (fmtr Frontmatter) ToParser() *parserv1.Frontmatter {
return &parserv1.Frontmatter{
Shell: fmtr.Shell,
Cwd: fmtr.Cwd,
SkipEnv: fmtr.SkipEnv,
Shell: fmtr.Shell,
Cwd: fmtr.Cwd,
SkipPrompts: fmtr.SkipPrompts,
}
}
90 changes: 45 additions & 45 deletions internal/gen/proto/go/runme/parser/v1/parser.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions internal/gen/proto/ts/runme/parser/v1/parser_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ export interface Frontmatter {
*/
cwd: string;
/**
* @generated from protobuf field: bool skip_env = 3;
* @generated from protobuf field: bool skip_prompts = 3;
*/
skipEnv: boolean;
skipPrompts: boolean;
}
/**
* @generated from protobuf message runme.parser.v1.DeserializeRequest
Expand Down
2 changes: 1 addition & 1 deletion internal/gen/proto/ts/runme/parser/v1/parser_pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Frontmatter$Type extends MessageType {
super("runme.parser.v1.Frontmatter", [
{ no: 1, name: "shell", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 2, name: "cwd", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 3, name: "skip_env", kind: "scalar", T: 8 /*ScalarType.BOOL*/ }
{ no: 3, name: "skip_prompts", kind: "scalar", T: 8 /*ScalarType.BOOL*/ }
]);
}
}
Expand Down
6 changes: 3 additions & 3 deletions internal/gen/proto/ts/runme/parser/v1/parser_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ export class Frontmatter extends Message<Frontmatter> {
cwd = "";

/**
* @generated from field: bool skip_env = 3;
* @generated from field: bool skip_prompts = 3;
*/
skipEnv = false;
skipPrompts = false;

constructor(data?: PartialMessage<Frontmatter>) {
super();
Expand All @@ -214,7 +214,7 @@ export class Frontmatter extends Message<Frontmatter> {
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "shell", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "cwd", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 3, name: "skip_env", kind: "scalar", T: 8 /* ScalarType.BOOL */ },
{ no: 3, name: "skip_prompts", kind: "scalar", T: 8 /* ScalarType.BOOL */ },
]);

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Frontmatter {
Expand Down
23 changes: 23 additions & 0 deletions pkg/project/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,29 @@ func Test_codeBlockFrontmatter(t *testing.T) {
assert.Equal(t, taskMemo["ZSH.md"].GetFrontmatter().Shell, "zsh")
}

func Test_codeBlockSkipPromptsFrontmatter(t *testing.T) {
cwd, err := os.Getwd()
require.NoError(t, err)

proj, err := NewDirectoryProject(filepath.Join(cwd, "../../", "examples", "frontmatter", "skipPrompts"), false, true, true, []string{})
require.NoError(t, err)

tasks, err := LoadProjectTasks(proj)
require.NoError(t, err)

t.Log(tasks)

taskMemo := make(map[string]FileCodeBlock)

for _, task := range tasks {
taskMemo[filepath.Base(task.GetFile())] = task
}

assert.Equal(t, taskMemo["DISABLED.md"].GetFrontmatter().SkipPrompts, false)
assert.Equal(t, taskMemo["ENABLED.md"].GetFrontmatter().SkipPrompts, true)
assert.Equal(t, taskMemo["NONE.md"].GetFrontmatter().SkipPrompts, false)
}

func projectDir() billy.Filesystem {
_, b, _, _ := runtime.Caller(0)
root := filepath.Join(
Expand Down

0 comments on commit 3ba24d4

Please sign in to comment.