Skip to content

Commit c8fefa6

Browse files
Merge pull request #168 from ibuildthecloud/chdir
feat: Add -C to change cwd of GPTScript process
2 parents 7e7d470 + f350d85 commit c8fefa6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pkg/cli/gptscript.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type GPTScript struct {
4747
ListTools bool `usage:"List built-in tools and exit"`
4848
Server bool `usage:"Start server"`
4949
ListenAddress string `usage:"Server listen address" default:"127.0.0.1:9090"`
50+
Chdir string `usage:"Change current working directory" short:"C"`
5051

5152
_client llm.Client `usage:"-"`
5253
}
@@ -130,6 +131,13 @@ func (r *GPTScript) listModels(ctx context.Context) error {
130131
}
131132

132133
func (r *GPTScript) Pre(*cobra.Command, []string) error {
134+
// chdir as soon as possible
135+
if r.Chdir != "" {
136+
if err := os.Chdir(r.Chdir); err != nil {
137+
return err
138+
}
139+
}
140+
133141
if r.DefaultModel != "" {
134142
builtin.SetDefaultModel(r.DefaultModel)
135143
}

0 commit comments

Comments
 (0)