Commit 15b948d7 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 8192b9bc
// 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.
// Zodb is a driver program for invoking zodbtools subcommands
package main
import (
)
var commandv = []Command{
// TODO analyze ?
// TODO cmp
{"dump", zodbtools.DumpMain},
{"info", zodbtools.InfoMain},
}
func usage() {
w := os.Stderr
fmt.Fprintf(w,
`Zodb is a tool for managing ZODB databases.
Usage:
zodb command [arguments]
The commands are:
`)
// TODO print commands
fmt.Fprintf(w,
`
Use "zodb help [command]" for more information about a command.
Additional help topics:
`)
// TODO print help topics
fmt.Fprintf(w,
`
Use "zodb help [topic]" for more information about that topic.
`)
}
// help shows general help or help for a command/topic
func help(argv []string) {
if len(argv) < 2 { // help topic ...
usage()
os.Exit(2)
}
topic := argv[1]
// topic can either be a command name or a help topic
command -> usage(os.Stdout)
// TODO topic
fmt.Fprintf(os.Stderr, "Unknown help topic `%s`. Run 'zodb help'.", topic)
os.Exit(2)
}
func main() {
flag.Usage = usage
flag.Parse()
argv := flag.Args()
if len(argv) == 0 {
usage()
os.Exit(2)
}
command = argv[0]
// help on a topic
if command == "help" {
help(argv)
return
}
// run subcommand
cmd, ok := commandDir[command]
if !ok {
fmt.Fprintf(os.Stderr, "zodb: unknown subcommand \"%s\"", command)
fmt.Fprintf(os.Stderr, "Run 'zodb help' for usage.")
os.Exit(2)
}
cmd.Main(argv)
}
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