feat: easier path setup through init --add-path
(#6)
* feat: init --add-path to provide env export * docs: mention --add-path in setup docs * chore: version update, 0.0.3
This commit is contained in:
parent
5e245f11cc
commit
5006ff3076
4 changed files with 21 additions and 4 deletions
10
README.md
10
README.md
|
@ -22,7 +22,15 @@ Pre-built binaries are not currently available. You can clone the repository and
|
||||||
You should find a suitable place for the binary (`/usr/local/bin` is a good location) and if not already included, add its location to `$PATH`.
|
You should find a suitable place for the binary (`/usr/local/bin` is a good location) and if not already included, add its location to `$PATH`.
|
||||||
|
|
||||||
Finally, run `v init` to create directories to store artifacts and state (under `~/.v` unless override using the
|
Finally, run `v init` to create directories to store artifacts and state (under `~/.v` unless override using the
|
||||||
`V_ROOT` environment variable) and add `~/.v/shims` to your `$PATH` as well.
|
`V_ROOT` environment variable). The following should also be added to your shell's configuration (i.e. `.zshrc`,
|
||||||
|
`.bashrc`, ...):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
export PATH=<path-to-v-executable>:$PATH
|
||||||
|
eval "$(v init --add-path)"
|
||||||
|
```
|
||||||
|
|
||||||
|
This will handle adding shim paths to your shell without hassle.
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
|
|
||||||
|
|
8
cli.go
8
cli.go
|
@ -6,6 +6,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Flags struct {
|
type Flags struct {
|
||||||
|
AddPath bool
|
||||||
NoCache bool
|
NoCache bool
|
||||||
Verbose bool
|
Verbose bool
|
||||||
}
|
}
|
||||||
|
@ -91,10 +92,13 @@ func collectFlags(args []string) Flags {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if arg == "--verbose" {
|
switch arg {
|
||||||
|
case "--verbose":
|
||||||
collected.Verbose = true
|
collected.Verbose = true
|
||||||
} else if arg == "--no-cache" {
|
case "--no-cache":
|
||||||
collected.NoCache = true
|
collected.NoCache = true
|
||||||
|
case "--add-path":
|
||||||
|
collected.AddPath = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,11 @@ func writeShim(shimPath string) error {
|
||||||
// Sets up directories and files used to store downloaded archives,
|
// Sets up directories and files used to store downloaded archives,
|
||||||
// installed runtimes and metadata.
|
// installed runtimes and metadata.
|
||||||
func Initialize(args []string, flags Flags, currentState State) error {
|
func Initialize(args []string, flags Flags, currentState State) error {
|
||||||
|
if flags.AddPath {
|
||||||
|
fmt.Printf("export PATH=%s:$PATH\n", GetStatePath("shims"))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
os.Mkdir(GetStatePath(), DEFAULT_PERMISSION)
|
os.Mkdir(GetStatePath(), DEFAULT_PERMISSION)
|
||||||
for _, dir := range DIRECTORIES {
|
for _, dir := range DIRECTORIES {
|
||||||
os.Mkdir(GetStatePath(dir), DEFAULT_PERMISSION)
|
os.Mkdir(GetStatePath(dir), DEFAULT_PERMISSION)
|
||||||
|
|
2
v.go
2
v.go
|
@ -5,7 +5,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Version = "0.0.2"
|
Version = "0.0.3"
|
||||||
Author = "Marc Cataford <hello@karnov.club>"
|
Author = "Marc Cataford <hello@karnov.club>"
|
||||||
Homepage = "https://github.com/mcataford/v"
|
Homepage = "https://github.com/mcataford/v"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue