Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
doc: write 'volt migrate' help documents
These commands are avalable:
* volt migrate -help
* volt help migrate
* volt migrate -help {migration target}
* volt help migrate {migration target}
  • Loading branch information
tyru committed Mar 31, 2018
1 parent ae5a003 commit 2ef2032
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 23 deletions.
13 changes: 9 additions & 4 deletions CMDREF.md
Expand Up @@ -211,12 +211,17 @@ Description

```
Usage
volt migrate [-help]
volt migrate [-help] {migration operation}
Description
Perform migration of $VOLTPATH/lock.json, which means volt converts old version lock.json structure into the latest version. This is always done automatically when reading lock.json content. For example, 'volt get <repos>' will install plugin, and migrate lock.json structure, and write it to lock.json after all. so the migrated content is written to lock.json automatically.
But, for example, 'volt list' does not write to lock.json but does read, so every time when running 'volt list' shows warning about lock.json is old.
To suppress this, running this command simply reads and writes migrated structure to lock.json.
Perform miscellaneous migration operations.
See detailed help for 'volt migrate -help {migration operation}'.
Available operations
lockjson
converts old lock.json format to the latest format
plugconf/config-func
converts s:config() function name to s:on_load_pre() in all plugconf files
```

# volt profile
Expand Down
5 changes: 3 additions & 2 deletions README.md
Expand Up @@ -66,8 +66,9 @@ Command
build [-full]
Build ~/.vim/pack/volt/ directory
migrate
Convert old version $VOLTPATH/lock.json structure into the latest version
migrate {migration operation}
Perform miscellaneous migration operations.
See 'volt migrate -help' for all available operations
self-upgrade [-check]
Upgrade to the latest volt command, or if -check was given, it only checks the newer version is available
Expand Down
8 changes: 5 additions & 3 deletions cmd/help.go
Expand Up @@ -87,8 +87,9 @@ Command
build [-full]
Build ~/.vim/pack/volt/ directory
migrate
Convert old version $VOLTPATH/lock.json structure into the latest version
migrate {migration operation}
Perform miscellaneous migration operations.
See 'volt migrate -help' for all available operations
self-upgrade [-check]
Upgrade to the latest volt command, or if -check was given, it only checks the newer version is available
Expand All @@ -115,6 +116,7 @@ func (cmd *helpCmd) Run(args []string) int {
logger.Errorf("Unknown command '%s'", args[0])
return 1
}
fs.Run([]string{"-help"})
args = append([]string{"-help"}, args[1:]...)
fs.Run(args)
return 0
}
33 changes: 24 additions & 9 deletions cmd/migrate.go
Expand Up @@ -24,14 +24,29 @@ func (cmd *migrateCmd) FlagSet() *flag.FlagSet {
fs := flag.NewFlagSet(os.Args[0], flag.ContinueOnError)
fs.SetOutput(os.Stdout)
fs.Usage = func() {
fmt.Print(`
Usage
args := fs.Args()
if len(args) > 0 {
m, err := migrate.GetMigrater(args[0])
if err != nil {
return
}
fmt.Println(m.Description(false))
fmt.Println()
cmd.helped = true
return
}

fmt.Println(`Usage
volt migrate [-help] {migration operation}
Description
Perform migration of $VOLTPATH/lock.json, which means volt converts old version lock.json structure into the latest version. This is always done automatically when reading lock.json content. For example, 'volt get <repos>' will install plugin, and migrate lock.json structure, and write it to lock.json after all. so the migrated content is written to lock.json automatically.
But, for example, 'volt list' does not write to lock.json but does read, so every time when running 'volt list' shows warning about lock.json is old.
To suppress this, running this command simply reads and writes migrated structure to lock.json.` + "\n\n")
Perform miscellaneous migration operations.
See detailed help for 'volt migrate -help {migration operation}'.
Available operations`)
cmd.showAvailableOps(func(line string) {
fmt.Println(line)
})
//fmt.Println("Options")
//fs.PrintDefaults()
fmt.Println()
Expand All @@ -47,7 +62,6 @@ func (cmd *migrateCmd) Run(args []string) int {
}
if err != nil {
logger.Error("Failed to parse args: " + err.Error())
cmd.showAvailableOps()
return 10
}

Expand All @@ -66,15 +80,16 @@ func (cmd *migrateCmd) parseArgs(args []string) (migrate.Migrater, error) {
if cmd.helped {
return nil, ErrShowedHelp
}
args = fs.Args()
if len(args) == 0 {
return nil, errors.New("please specify migration operation")
}
return migrate.GetMigrater(args[0])
}

func (cmd *migrateCmd) showAvailableOps() {
logger.Info("Available migrate operations are:")
func (cmd *migrateCmd) showAvailableOps(write func(string)) {
for _, m := range migrate.ListMigraters() {
logger.Infof(" %s - %s", m.Name(), m.Description())
write(fmt.Sprintf(" %s", m.Name()))
write(fmt.Sprintf(" %s", m.Description(true)))
}
}
13 changes: 11 additions & 2 deletions cmd/migrate/lockjson.go
Expand Up @@ -18,8 +18,17 @@ func (*lockjsonMigrater) Name() string {
return "lockjson"
}

func (*lockjsonMigrater) Description() string {
return "converts old lock.json format to the latest format"
func (m *lockjsonMigrater) Description(brief bool) string {
if brief {
return "converts old lock.json format to the latest format"
}
return `Usage
volt migrate [-help] ` + m.Name() + `
Description
Perform migration of $VOLTPATH/lock.json, which means volt converts old version lock.json structure into the latest version. This is always done automatically when reading lock.json content. For example, 'volt get <repos>' will install plugin, and migrate lock.json structure, and write it to lock.json after all. so the migrated content is written to lock.json automatically.
But, for example, 'volt list' does not write to lock.json but does read, so every time when running 'volt list' shows warning about lock.json is old.
To suppress this, running this command simply reads and writes migrated structure to lock.json.`
}

func (*lockjsonMigrater) Migrate() error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/migrate/migrater.go
Expand Up @@ -9,7 +9,7 @@ import (
type Migrater interface {
Migrate() error
Name() string
Description() string
Description(brief bool) string
}

var migrateOps = make(map[string]Migrater)
Expand Down
13 changes: 11 additions & 2 deletions cmd/migrate/plugconf-config-func.go
Expand Up @@ -26,8 +26,17 @@ func (*plugconfConfigMigrater) Name() string {
return "plugconf/config-func"
}

func (*plugconfConfigMigrater) Description() string {
return "converts s:config() function name to s:on_load_pre() in all plugconf files"
func (m *plugconfConfigMigrater) Description(brief bool) string {
if brief {
return "converts s:config() function name to s:on_load_pre() in all plugconf files"
}
return `Usage
volt migrate [-help] ` + m.Name() + `
Description
Perform migration of the function name of s:config() functions in plugconf files of all plugins. All s:config() functions are renamed to s:on_load_pre().
"s:config()" is a old function name (see https://github.com/vim-volt/volt/issues/196).
All plugconf files are replaced with new contents.`
}

func (*plugconfConfigMigrater) Migrate() error {
Expand Down

0 comments on commit 2ef2032

Please sign in to comment.