-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from mutablelogic/v1
Updated api
- Loading branch information
Showing
8 changed files
with
90 additions
and
20 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,12 @@ | ||
package main | ||
|
||
type DeleteCmd struct { | ||
Model string `arg:"" name:"model" help:"Model to delete"` | ||
} | ||
|
||
func (cmd *DeleteCmd) Run(ctx *Globals) error { | ||
if err := ctx.client.DeleteModel(ctx.ctx, cmd.Model); err != nil { | ||
return err | ||
} | ||
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,22 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/djthorpe/go-tablewriter" | ||
) | ||
|
||
type DownloadCmd struct { | ||
Model string `arg:"" name:"model" help:"Model to download (must end in .bin)"` | ||
} | ||
|
||
func (cmd *DownloadCmd) Run(ctx *Globals) error { | ||
model, err := ctx.client.DownloadModel(ctx.ctx, cmd.Model, func(status string, cur, total int64) { | ||
pct := fmt.Sprintf("%02d%%", int(100*float64(cur)/float64(total))) | ||
ctx.writer.Writeln(pct, status) | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
return ctx.writer.Write(model, tablewriter.OptHeader()) | ||
} |
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,13 @@ | ||
package main | ||
|
||
import "github.com/djthorpe/go-tablewriter" | ||
|
||
type ModelsCmd struct{} | ||
|
||
func (cmd *ModelsCmd) Run(ctx *Globals) error { | ||
if models, err := ctx.client.ListModels(ctx.ctx); err != nil { | ||
return err | ||
} else { | ||
return ctx.writer.Write(models, tablewriter.OptHeader()) | ||
} | ||
} |
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
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