Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
62dc2806
Commit
62dc2806
authored
Apr 25, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
e2266200
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
95 additions
and
42 deletions
+95
-42
go/neo/cmd/neo/neo.go
go/neo/cmd/neo/neo.go
+35
-8
go/neo/command.go
go/neo/command.go
+29
-0
go/zodb/cmd/zodb/zodb.go
go/zodb/cmd/zodb/zodb.go
+5
-5
go/zodb/zodbtools/command.go
go/zodb/zodbtools/command.go
+11
-13
go/zodb/zodbtools/help.go
go/zodb/zodbtools/help.go
+15
-16
No files found.
go/neo/cmd/neo/neo.go
View file @
62dc2806
...
@@ -22,6 +22,8 @@ import (
...
@@ -22,6 +22,8 @@ import (
"flag"
"flag"
"fmt"
"fmt"
"os"
"os"
"../../../neo"
)
)
func
usage
()
{
func
usage
()
{
...
@@ -36,31 +38,56 @@ Usage:
...
@@ -36,31 +38,56 @@ Usage:
The commands are:
The commands are:
`
)
`
)
for
_
,
cmd
:=
range
zodbtools
.
AllCommands
()
{
for
_
,
cmd
:=
range
neo
.
Commands
{
fmt
.
Fprintf
(
w
,
"
\t
%-11s %s
\n
"
,
cmd
.
Name
,
cmd
.
Summary
)
fmt
.
Fprintf
(
w
,
"
\t
%-11s %s
\n
"
,
cmd
.
Name
,
cmd
.
Summary
)
}
}
fmt
.
Fprintf
(
w
,
fmt
.
Fprintf
(
w
,
`
`
Use "
zodb
help [command]" for more information about a command.
Use "
neo
help [command]" for more information about a command.
Additional help topics:
Additional help topics:
`
)
`
)
for
_
,
topic
:=
range
zodbtools
.
AllHelpTopics
()
{
for
_
,
topic
:=
range
neo
.
HelpTopics
{
fmt
.
Fprintf
(
w
,
"
\t
%-11s %s
\n
"
,
topic
.
Name
,
topic
.
Summary
)
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 "
neo
help [topic]" for more information about that topic.
`
)
`
)
}
}
// TODO help()
// 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
:=
neo
.
Commands
.
Lookup
(
topic
)
if
command
!=
nil
{
command
.
Usage
(
os
.
Stdout
)
os
.
Exit
(
0
)
}
helpTopic
:=
neo
.
HelpTopics
.
Lookup
(
topic
)
if
helpTopic
!=
nil
{
fmt
.
Println
(
helpTopic
.
Text
)
os
.
Exit
(
0
)
}
fmt
.
Fprintf
(
os
.
Stderr
,
"Unknown help topic `%s`. Run 'neo help'.
\n
"
,
topic
)
os
.
Exit
(
2
)
}
func
main
()
{
func
main
()
{
flag
.
Usage
=
usage
flag
.
Usage
=
usage
...
@@ -81,10 +108,10 @@ func main() {
...
@@ -81,10 +108,10 @@ func main() {
}
}
// run subcommand
// run subcommand
cmd
:=
zodbtools
.
LookupCommand
(
command
)
cmd
:=
neo
.
Commands
.
Lookup
(
command
)
if
cmd
==
nil
{
if
cmd
==
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"
zodb
: unknown subcommand
\"
%s
\"
"
,
command
)
fmt
.
Fprintf
(
os
.
Stderr
,
"
neo
: unknown subcommand
\"
%s
\"
"
,
command
)
fmt
.
Fprintf
(
os
.
Stderr
,
"Run '
zodb
help' for usage."
)
fmt
.
Fprintf
(
os
.
Stderr
,
"Run '
neo
help' for usage."
)
os
.
Exit
(
2
)
os
.
Exit
(
2
)
}
}
...
...
go/neo/command.go
0 → 100644
View file @
62dc2806
// 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
neo
// registry of all commands & help topics
import
"../zodb/zodbtools"
var
Commands
=
zodbtools
.
CommandRegistry
{
{
"storage"
,
storageSummary
,
storageUsage
,
storageMain
},
}
var
HelpTopics
=
zodbtools
.
HelpRegistry
{
// XXX for now empty
}
go/zodb/cmd/zodb/zodb.go
View file @
62dc2806
...
@@ -40,7 +40,7 @@ Usage:
...
@@ -40,7 +40,7 @@ Usage:
The commands are:
The commands are:
`
)
`
)
for
_
,
cmd
:=
range
zodbtools
.
AllCommands
()
{
for
_
,
cmd
:=
range
zodbtools
.
Commands
{
fmt
.
Fprintf
(
w
,
"
\t
%-11s %s
\n
"
,
cmd
.
Name
,
cmd
.
Summary
)
fmt
.
Fprintf
(
w
,
"
\t
%-11s %s
\n
"
,
cmd
.
Name
,
cmd
.
Summary
)
}
}
...
@@ -53,7 +53,7 @@ Additional help topics:
...
@@ -53,7 +53,7 @@ Additional help topics:
`
)
`
)
for
_
,
topic
:=
range
zodbtools
.
AllHelpTopics
()
{
for
_
,
topic
:=
range
zodbtools
.
HelpTopics
{
fmt
.
Fprintf
(
w
,
"
\t
%-11s %s
\n
"
,
topic
.
Name
,
topic
.
Summary
)
fmt
.
Fprintf
(
w
,
"
\t
%-11s %s
\n
"
,
topic
.
Name
,
topic
.
Summary
)
}
}
...
@@ -75,13 +75,13 @@ func help(argv []string) {
...
@@ -75,13 +75,13 @@ func help(argv []string) {
topic
:=
argv
[
1
]
topic
:=
argv
[
1
]
// topic can either be a command name or a help topic
// topic can either be a command name or a help topic
command
:=
zodbtools
.
LookupCommand
(
topic
)
command
:=
zodbtools
.
Commands
.
Lookup
(
topic
)
if
command
!=
nil
{
if
command
!=
nil
{
command
.
Usage
(
os
.
Stdout
)
command
.
Usage
(
os
.
Stdout
)
os
.
Exit
(
0
)
os
.
Exit
(
0
)
}
}
helpTopic
:=
zodbtools
.
LookupHelpTopic
(
topic
)
helpTopic
:=
zodbtools
.
HelpTopics
.
Lookup
(
topic
)
if
helpTopic
!=
nil
{
if
helpTopic
!=
nil
{
fmt
.
Println
(
helpTopic
.
Text
)
fmt
.
Println
(
helpTopic
.
Text
)
os
.
Exit
(
0
)
os
.
Exit
(
0
)
...
@@ -110,7 +110,7 @@ func main() {
...
@@ -110,7 +110,7 @@ func main() {
}
}
// run subcommand
// run subcommand
cmd
:=
zodbtools
.
LookupCommand
(
command
)
cmd
:=
zodbtools
.
Commands
.
Lookup
(
command
)
if
cmd
==
nil
{
if
cmd
==
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"zodb: unknown subcommand
\"
%s
\"
"
,
command
)
fmt
.
Fprintf
(
os
.
Stderr
,
"zodb: unknown subcommand
\"
%s
\"
"
,
command
)
fmt
.
Fprintf
(
os
.
Stderr
,
"Run 'zodb help' for usage."
)
fmt
.
Fprintf
(
os
.
Stderr
,
"Run 'zodb help' for usage."
)
...
...
go/zodb/zodbtools/command.go
View file @
62dc2806
...
@@ -28,17 +28,11 @@ type Command struct {
...
@@ -28,17 +28,11 @@ type Command struct {
Main
func
(
argv
[]
string
)
Main
func
(
argv
[]
string
)
}
}
// registry of all commands
// CommandRegistry is ordered collection of Commands
var
cmdv
=
[]
Command
{
type
CommandRegistry
[]
Command
// NOTE the order commands are listed here is the order how they will appear in help
// TODO analyze ?
// TODO cmp
{
"dump"
,
dumpSummary
,
dumpUsage
,
dumpMain
},
{
"info"
,
infoSummary
,
infoUsage
,
infoMain
},
}
// Lookup
Command
returns Command with corresponding name or nil
// Lookup returns Command with corresponding name or nil
func
LookupCommand
(
command
string
)
*
Command
{
func
(
cmdv
CommandRegistry
)
Lookup
(
command
string
)
*
Command
{
for
i
:=
range
cmdv
{
for
i
:=
range
cmdv
{
if
cmdv
[
i
]
.
Name
==
command
{
if
cmdv
[
i
]
.
Name
==
command
{
return
&
cmdv
[
i
]
return
&
cmdv
[
i
]
...
@@ -47,7 +41,11 @@ func LookupCommand(command string) *Command {
...
@@ -47,7 +41,11 @@ func LookupCommand(command string) *Command {
return
nil
return
nil
}
}
// AllCommands returns list of all zodbtools commands
// registry of all zodbtools commands
func
AllCommands
()
[]
Command
{
var
Commands
=
CommandRegistry
{
return
cmdv
// NOTE the order commands are listed here is the order how they will appear in help
// TODO analyze ?
// TODO cmp
{
"dump"
,
dumpSummary
,
dumpUsage
,
dumpMain
},
{
"info"
,
infoSummary
,
infoUsage
,
infoMain
},
}
}
go/zodb/zodbtools/help.go
View file @
62dc2806
...
@@ -18,12 +18,26 @@
...
@@ -18,12 +18,26 @@
package
zodbtools
package
zodbtools
// registry for all help topics
// registry for all help topics
// HelpTopic describes one help topic
type
HelpTopic
struct
{
type
HelpTopic
struct
{
Name
string
Name
string
Summary
string
Summary
string
Text
string
Text
string
}
}
// HelpRegistry is ordered collection of HelpTopics
type
HelpRegistry
[]
HelpTopic
// Lookup returns HelpTopic with corresponding name or nil
func
(
helpv
HelpRegistry
)
Lookup
(
topic
string
)
*
HelpTopic
{
for
i
:=
range
helpv
{
if
helpv
[
i
]
.
Name
==
topic
{
return
&
helpv
[
i
]
}
}
return
nil
}
const
helpZURL
=
const
helpZURL
=
`Almost every zodb command works with a database.
`Almost every zodb command works with a database.
A database can be specified by way of providing URL for its storage.
A database can be specified by way of providing URL for its storage.
...
@@ -52,21 +66,6 @@ Please see zodburi documentation for full details:
...
@@ -52,21 +66,6 @@ Please see zodburi documentation for full details:
http://docs.pylonsproject.org/projects/zodburi/
http://docs.pylonsproject.org/projects/zodburi/
`
`
var
helpv
=
[]
HelpTopic
{
var
HelpTopics
=
HelpRegistry
{
{
"zurl"
,
"specifying database URL"
,
helpZURL
},
{
"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
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment