-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
18da184
commit 76385e0
Showing
10 changed files
with
253 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
echo "${input}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package assemble | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"io" | ||
|
||
"github.com/acorn-io/gptscript/pkg/types" | ||
) | ||
|
||
var Header = []byte("GPTSCRIPT\x00") | ||
|
||
func Assemble(ctx context.Context, tool types.Tool, output io.Writer) error { | ||
if _, err := output.Write(Header); err != nil { | ||
return err | ||
} | ||
return json.NewEncoder(output).Encode(tool) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package input | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"os" | ||
"strings" | ||
) | ||
|
||
func FromArgs(args []string) string { | ||
return strings.Join(args, " ") | ||
} | ||
|
||
func FromFile(file string) (string, error) { | ||
if file == "-" { | ||
log.Debugf("reading stdin") | ||
data, err := io.ReadAll(os.Stdin) | ||
if err != nil { | ||
return "", fmt.Errorf("reading stdin: %w", err) | ||
} | ||
return string(data), nil | ||
} else if file != "" { | ||
log.Debugf("reading file %s", file) | ||
data, err := os.ReadFile(file) | ||
if err != nil { | ||
return "", fmt.Errorf("reading %s: %w", file, err) | ||
} | ||
return string(data), nil | ||
} | ||
|
||
return "", nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package input | ||
|
||
import "github.com/acorn-io/gptscript/pkg/mvl" | ||
|
||
var log = mvl.Package() |
Oops, something went wrong.