Commit 0e825b2f authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 098dbccd
...@@ -39,7 +39,6 @@ Usage: ...@@ -39,7 +39,6 @@ Usage:
The commands are: The commands are:
`) `)
// TODO print commands
for _, cmd := range zodbtools.AllCommands() { for _, cmd := range zodbtools.AllCommands() {
fmt.Fprintf(w, "\t%-11s %s\n", cmd.Name, cmd.Summary) fmt.Fprintf(w, "\t%-11s %s\n", cmd.Name, cmd.Summary)
} }
...@@ -50,14 +49,17 @@ The commands are: ...@@ -50,14 +49,17 @@ The commands are:
Use "zodb help [command]" for more information about a command. Use "zodb help [command]" for more information about a command.
Additional help topics: Additional help topics:
`) `)
// TODO print help topics for _, topic := range zodbtools.AllHelpTopics() {
fmt.Fprintf(w, "\t%-11s %s\n", topic.Name, topic.Summary)
}
fmt.Fprintf(w, fmt.Fprintf(w,
` `
Use "zodb help [topic]" for more information about that topic. Use "zodb help [topic]" for more information about that topic.
`) `)
} }
...@@ -78,8 +80,11 @@ func help(argv []string) { ...@@ -78,8 +80,11 @@ func help(argv []string) {
os.Exit(0) os.Exit(0)
} }
// TODO topic helpTopic := zodbtools.LookupHelpTopic(topic)
if helpTopic != nil {
fmt.Println(helpTopic.Text)
os.Exit(0)
}
fmt.Fprintf(os.Stderr, "Unknown help topic `%s`. Run 'zodb help'.\n", topic) fmt.Fprintf(os.Stderr, "Unknown help topic `%s`. Run 'zodb help'.\n", topic)
os.Exit(2) os.Exit(2)
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
// See COPYING file for full licensing terms. // See COPYING file for full licensing terms.
package zodbtools package zodbtools
// registry for all commands
import ( import (
"io" "io"
......
// Copyright (C) 2017 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Open Source Initiative approved licenses and Convey
// the resulting work. Corresponding source of such a combination shall include
// the source code for all other software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
package zodbtools
// registry for all help topics
type HelpTopic struct {
Name string
Summary string
Text string
}
const helpZURL =
`Almost every zodb command works with a database.
A database can be specified by way of providing URL for its storage.
The most general way to specify a storage is via preparing file with
ZConfig-based storage definition, e.g.
%import neo.client
<NEOStorage>
master_nodes ...
name ...
</NEOStorage>
and using path to that file with zconfig:// schema:
zconfig://<path-to-zconfig-storage-definition>
There are also following simpler ways:
- neo://<db>@<master> for a NEO database
- zeo://<host>:<port> for a ZEO database
- /path/to/file for a FileStorage database
Please see zodburi documentation for full details:
http://docs.pylonsproject.org/projects/zodburi/
`
var helpv = []HelpTopic{
{"zurl", "specifying database URL", helpZURL},
}
// LookupHelpTopic returns HelpTopic with corresponding name or nil
func LookupHelpTopic(topic string) *HelpTopic {
for i := range helpv {
if helpv[i].Name == topic {
return &helpv[i]
}
}
return nil
}
// AllHelpTopics returns list of all zodbtools help topics
func AllHelpTopics() []HelpTopic {
return helpv
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment