Skip to content

Commit

Permalink
refactor(binary): rename instill to inst (#191)
Browse files Browse the repository at this point in the history
Because

- to keep the binary name short

This commit

- rename `instill` to `inst`
  • Loading branch information
pinglin committed Oct 4, 2023
1 parent cea34c9 commit ccaf8f5
Show file tree
Hide file tree
Showing 41 changed files with 136 additions and 158 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:
run: go test -race ./...

- name: Build
run: go build -v ./cmd/instill
run: go build -v ./cmd/inst
18 changes: 9 additions & 9 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project_name: instill
project_name: inst

release:
prerelease: auto
Expand All @@ -15,8 +15,8 @@ before:

builds:
- <<: &build_defaults
binary: bin/instill
main: ./cmd/instill
binary: bin/inst
main: ./cmd/inst
ldflags:
- -s -w
- -X github.com/instill-ai/cli/internal/build.Version={{ .Version }}
Expand Down Expand Up @@ -76,16 +76,16 @@ brews:
- tap:
owner: instill-ai
name: homebrew-tap
description: Instill AI's official command-line tool
description: Instill AI's command-line tool
homepage: https://github.com/instill-ai/cli
license: "Apache-2.0"
commit_author:
name: droplet-bot
email: [email protected]
install: |
bin.install "bin/instill"
(bash_completion/"instill").write `#{bin}/instill completion -s bash`
(fish_completion/"instill.fish").write `#{bin}/instill completion -s fish`
(zsh_completion/"_instill").write `#{bin}/instill completion -s zsh`
bin.install "bin/inst"
(bash_completion/"inst").write `#{bin}/inst completion -s bash`
(fish_completion/"inst.fish").write `#{bin}/inst completion -s fish`
(zsh_completion/"_inst").write `#{bin}/inst completion -s zsh`
test: |
assert_match "instill version #{version}", shell_output("#{bin}/instill --version")
assert_match "inst version #{version}", shell_output("#{bin}/inst --version")
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ endif

## The following tasks delegate to `script/build.go` so they can be run cross-platform.

.PHONY: bin/instill$(EXE)
bin/instill$(EXE): script/build
.PHONY: bin/inst$(EXE)
bin/inst$(EXE): script/build
@script/build $@

script/build: script/build.go
Expand All @@ -22,7 +22,7 @@ script/build: script/build.go
.PHONY: clean
clean:
rm -f script/build
rm -f bin/instill
rm -f bin/inst

# just a convenience task around `go test`
.PHONY: test
Expand All @@ -38,10 +38,10 @@ bindir := ${prefix}/bin
mandir := ${prefix}/share/man

.PHONY: install
install: bin/instill
install: bin/inst
install -d ${DESTDIR}${bindir}
install -m755 bin/instill ${DESTDIR}${bindir}/
install -m755 bin/inst ${DESTDIR}${bindir}/

.PHONY: uninstall
uninstall:
rm -f ${DESTDIR}${bindir}/instill
rm -f ${DESTDIR}${bindir}/inst
35 changes: 11 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
[![License](https://img.shields.io/github/license/instill-ai/cli.svg?color=lightblue&label=License)](./License.md)
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-lightblue.svg)](.github/code_of_conduct.md)

`instill` is the command line interface for **Instill Cloud**.
`inst` is the command line interface for **Instill Core / Cloud**.

## Table of contents <!-- omit in toc -->
- [What is Instill Cloud?](#what-is-instill-cloud)
- [Installation](#installation)
- [Usage examples](#usage-examples)
- [Issues and discussions](#issues-and-discussions)

## What is Instill Cloud?
Expand All @@ -41,51 +42,37 @@ Instill AI is on a mission to make AI accessible to everyone. With **Instill Clo

To install:
```
brew install instill-ai/tap/instill
brew install instill-ai/tap/inst
```

To upgrade:
```
brew upgrade instill-ai/tap/instill
brew upgrade instill-ai/tap/inst
```

## Usage examples

```bash
# log in
$ instill auth login
$ inst auth login

# list pipelines
$ instill api pipelines
$ inst api pipelines

# list models
$ instill api model/models
$ inst api model/models

# add parameters to a GET request
$ instill api model/models?visibility=public
$ inst api model/models?visibility=public

# list instances
$ instill instances list

# selected a default instance
$ instill instances set-default my-host.com

# add an instance
$ instill instances add instill.localhost \
--oauth2 auth.instill.tech \
--audience https://instill.tech \
--issuer https://auth.instill.tech/ \
--secret YOUR_SECRET \
--client-id CLIENT_ID

# add parameters to a POST request
$ instill api -X POST oauth2/token?audience=...&grant_type=...
$ inst instances list

# add nested JSON body to a POST request
$ jq -n '{"contents":[{"url": "https://artifacts.instill.tech/dog.jpg"}]}' | instill api demo/tasks/classification/outputs --input -
$ jq -n '{"contents":[{"url": "https://artifacts.instill.tech/dog.jpg"}]}' | inst api demo/tasks/classification/outputs --input -

# set a custom HTTP header
$ instill api -H 'Authorization: Basic mytoken' ...
$ inst api -H 'Authorization: Basic mytoken' ...
```

## Issues and discussions
Expand Down
14 changes: 7 additions & 7 deletions cmd/instill/main.go → cmd/inst/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func mainRun() exitCode {
}
}

// Enable running instill from Windows File Explorer's address bar. Without this, the user is told to stop and run from a
// Enable running inst from Windows File Explorer's address bar. Without this, the user is told to stop and run from a
// terminal. With this, a user can clone a repo (or take other actions) directly from explorer.
if len(os.Args) > 1 && os.Args[1] != "" {
cobra.MousetrapHelpText = ""
Expand All @@ -106,7 +106,7 @@ func mainRun() exitCode {
expandedArgs = os.Args[1:]
}

// translate `instill help <command>` to `instill <command> --help` for extensions
// translate `inst help <command>` to `inst <command> --help` for extensions
if len(expandedArgs) == 2 && expandedArgs[0] == "help" && !hasCommand(rootCmd, expandedArgs[1:]) {
expandedArgs = []string{expandedArgs[1], "--help"}
}
Expand All @@ -119,7 +119,7 @@ func mainRun() exitCode {
if cmdutil.IsAuthCheckEnabled(cmd) && !cmdutil.CheckAuth(cfg) {
fmt.Fprintln(stderr, cs.Bold("Welcome to Instill CLI!"))
fmt.Fprintln(stderr)
fmt.Fprintln(stderr, "To authenticate, please run `instill auth login`.")
fmt.Fprintln(stderr, "To authenticate, please run `inst auth login`.")
return authError
}

Expand All @@ -145,13 +145,13 @@ func mainRun() exitCode {

if strings.Contains(err.Error(), "Incorrect function") {
fmt.Fprintln(stderr, "You appear to be running in MinTTY without pseudo terminal support.")
fmt.Fprintln(stderr, "To learn about workarounds for this error, run: instill help mintty")
fmt.Fprintln(stderr, "To learn about workarounds for this error, run: inst help mintty")
return exitError
}

var httpErr api.HTTPError
if errors.As(err, &httpErr) && httpErr.StatusCode == 401 {
fmt.Fprintln(stderr, "Try authenticating with: instill auth login")
fmt.Fprintln(stderr, "Try authenticating with: inst auth login")
}

return exitError
Expand All @@ -172,7 +172,7 @@ func mainRun() exitCode {
ansi.Color(buildVersion, "cyan"),
ansi.Color(newRelease.Version, "cyan"))
if isHomebrew {
fmt.Fprintf(stderr, "To upgrade, run: %s\n", "brew update && brew upgrade instill")
fmt.Fprintf(stderr, "To upgrade, run: %s\n", "brew update && brew upgrade inst")
}
fmt.Fprintf(stderr, "%s\n\n",
ansi.Color(newRelease.URL, "yellow"))
Expand Down Expand Up @@ -265,7 +265,7 @@ func isRecentRelease(publishedAt time.Time) bool {
return !publishedAt.IsZero() && time.Since(publishedAt) < time.Hour*24
}

// Check whether the instill binary was found under the Homebrew prefix
// Check whether the inst binary was found under the Homebrew prefix
func isUnderHomebrew(instillBinary string) bool {
brewExe, err := safeexec.LookPath("brew")
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions internal/config/config_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"gopkg.in/yaml.v3"
)

// This interface describes interacting with some persistent configuration for instill.
// Config is the interface describes interacting with some persistent configuration for inst.
type Config interface {
Get(string, string) (string, error)
GetWithSource(string, string) (string, string, error)
Expand Down Expand Up @@ -146,7 +146,7 @@ func NewBlankRoot() *yaml.Node {
Value: "https",
},
{
HeadComment: "What editor instill should run. If blank, will refer to environment.",
HeadComment: "What editor inst should run. If blank, will refer to environment.",
Kind: yaml.ScalarNode,
Value: "editor",
},
Expand Down Expand Up @@ -182,7 +182,7 @@ func NewBlankRoot() *yaml.Node {
Value: "",
},
{
HeadComment: "What web browser instill should use when opening URLs. If blank, will refer to environment.",
HeadComment: "What web browser inst should use when opening URLs. If blank, will refer to environment.",
Kind: yaml.ScalarNode,
Value: "browser",
},
Expand Down
4 changes: 2 additions & 2 deletions internal/config/config_type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ func Test_defaultConfig(t *testing.T) {
expected := heredoc.Doc(`
# What protocol to use when performing git operations. Supported values: https
protocol: https
# What editor instill should run. If blank, will refer to environment.
# What editor inst should run. If blank, will refer to environment.
editor:
# When to interactively prompt. This is a global config that cannot be overridden by hostname. Supported values: enabled, disabled
prompt: enabled
# A pager program to send command output to, e.g. "less". Set the value to "cat" to disable the pager.
pager:
# The path to a unix socket through which send HTTP connections. If blank, HTTP traffic will be handled by net/http.DefaultTransport.
http_unix_socket:
# What web browser instill should use when opening URLs. If blank, will refer to environment.
# What web browser inst should use when opening URLs. If blank, will refer to environment.
browser:
`)
assert.Equal(t, expected, mainBuf.String())
Expand Down
2 changes: 1 addition & 1 deletion internal/run/stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type T interface {
Errorf(string, ...interface{})
}

// Stub installs a catch-all for all external commands invoked from instill. It returns a restore func that, when
// Stub installs a catch-all for all external commands invoked from inst. It returns a restore func that, when
// invoked from tests, fails the current test if some stubs that were registered were never matched.
func Stub() (*CommandStubber, func(T)) {
cs := &CommandStubber{}
Expand Down
14 changes: 7 additions & 7 deletions pkg/cmd/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,22 @@ func NewCmdApi(f *cmdutil.Factory, runF func(*ApiOptions) error) *cobra.Command
`, "`"),
Example: heredoc.Doc(`
# list pipelines
$ instill api vdp/v1alpha/pipelines
$ inst api vdp/v1alpha/pipelines
# list models
$ instill api model/v1alpha/models
$ inst api model/v1alpha/models
# get user profile
$ instill api base/v1alpha/users/me
$ inst api base/v1alpha/users/me
# add parameters to a GET request
$ instill api model/v1alpha/models?visibility=public
$ inst api model/v1alpha/models?visibility=public
# add nested JSON body to a POST request
$ jq -n '{"inputs":[{"image": <your image base64 encoded string>}]}' | instill api vdp/v1alpha/pipelines/trigger --input -
$ jq -n '{"inputs":[{"image": <your image base64 encoded string>}]}' | inst api vdp/v1alpha/pipelines/trigger --input -
# set a custom HTTP header
$ instill api -H 'Authorization: Basic ...'
$ inst api -H 'Authorization: Basic ...'
`),
Args: cobra.ExactArgs(1),
RunE: func(c *cobra.Command, args []string) error {
Expand Down Expand Up @@ -317,7 +317,7 @@ func processResponse(resp *http.Response, opts *ApiOptions, headersOutputStream
}

if serverError != "" {
fmt.Fprintf(opts.IO.ErrOut, "instill: %s\n", serverError)
fmt.Fprintf(opts.IO.ErrOut, "inst: %s\n", serverError)
err = cmdutil.SilentError
return
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func Test_apiRun(t *testing.T) {
},
err: cmdutil.SilentError,
stdout: `{"message": "THIS IS FINE"}`,
stderr: "instill: THIS IS FINE (HTTP 400)\n",
stderr: "inst: THIS IS FINE (HTTP 400)\n",
},
{
name: "REST string errors",
Expand All @@ -297,7 +297,7 @@ func Test_apiRun(t *testing.T) {
},
err: cmdutil.SilentError,
stdout: `{"errors": ["ALSO", "FINE"]}`,
stderr: "instill: ALSO\nFINE\n",
stderr: "inst: ALSO\nFINE\n",
},
{
name: "failure",
Expand All @@ -307,7 +307,7 @@ func Test_apiRun(t *testing.T) {
},
err: cmdutil.SilentError,
stdout: `gateway timeout`,
stderr: "instill: HTTP 502\n",
stderr: "inst: HTTP 502\n",
},
{
name: "silent",
Expand Down
6 changes: 4 additions & 2 deletions pkg/cmd/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ package auth
import (
"github.com/spf13/cobra"

"github.com/instill-ai/cli/pkg/cmdutil"

authLoginCmd "github.com/instill-ai/cli/pkg/cmd/auth/login"
authLogoutCmd "github.com/instill-ai/cli/pkg/cmd/auth/logout"
authStatusCmd "github.com/instill-ai/cli/pkg/cmd/auth/status"
"github.com/instill-ai/cli/pkg/cmdutil"
)

// NewCmdAuth creates the `auth` command
func NewCmdAuth(f *cmdutil.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "auth <command>",
Short: "Login and logout",
Long: `Manage instill's authentication state.`,
Long: `Manage authentication state.`,
}

cmdutil.DisableAuthCheck(cmd)
Expand Down
9 changes: 4 additions & 5 deletions pkg/cmd/auth/login/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ import (
"github.com/instill-ai/cli/internal/instance"
"github.com/instill-ai/cli/internal/oauth2"
"github.com/instill-ai/cli/pkg/cmd/factory"
"github.com/instill-ai/cli/pkg/cmd/local"
"github.com/instill-ai/cli/pkg/cmdutil"
"github.com/instill-ai/cli/pkg/iostreams"
"github.com/instill-ai/cli/pkg/prompt"

"github.com/instill-ai/cli/pkg/cmd/local"
)

type LoginOptions struct {
Expand Down Expand Up @@ -49,7 +48,7 @@ func NewCmdLogin(f *cmdutil.Factory, runF func(*LoginOptions) error) *cobra.Comm
`),
Example: heredoc.Doc(`
# start login
$ instill auth login
$ inst auth login
`),
RunE: func(cmd *cobra.Command, args []string) error {

Expand Down Expand Up @@ -97,7 +96,7 @@ func loginRun(f *cmdutil.Factory, opts *LoginOptions) error {
stderr := cmdFactory.IOStreams.ErrOut
cs := cmdFactory.IOStreams.ColorScheme()

fmt.Fprintln(stderr, cs.Bold("No host.yml config, creating one with the default host \"api.instill.tech\"..."))
fmt.Fprintln(stderr, cs.Bold("No hosts.yml config, creating one with the default host \"api.instill.tech\"..."))
fmt.Fprintln(stderr, config.HostsConfigFile())
fmt.Fprintln(stderr, "")
} else {
Expand Down Expand Up @@ -148,7 +147,7 @@ func loginRun(f *cmdutil.Factory, opts *LoginOptions) error {
e := heredoc.Docf(`ERROR: OAuth2 config isn't complete for '%s'
You can fix it with:
$ instill instances edit %s \
$ inst instances edit %s \
--oauth2 HOSTNAME \
--client-id CLIENT_ID \
--client-secret CLIENT_SECRET`, host.APIHostname, host.APIHostname)
Expand Down
Loading

0 comments on commit ccaf8f5

Please sign in to comment.