good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
502a2bd6
Unverified
Commit
502a2bd6
authored
May 3, 2017
by
Bas van Kervel
Browse files
Options
Downloads
Patches
Plain Diff
cmd/geth: reorganise console/attach commands/flags
parent
8b517d7f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
cmd/geth/consolecmd.go
+27
-19
27 additions, 19 deletions
cmd/geth/consolecmd.go
cmd/geth/main.go
+51
-47
51 additions, 47 deletions
cmd/geth/main.go
cmd/utils/flags.go
+1
-1
1 addition, 1 deletion
cmd/utils/flags.go
with
79 additions
and
67 deletions
cmd/geth/consolecmd.go
+
27
−
19
View file @
502a2bd6
...
...
@@ -28,42 +28,47 @@ import (
"gopkg.in/urfave/cli.v1"
)
var
(
consoleFlags
=
[]
cli
.
Flag
{
utils
.
JSpathFlag
,
utils
.
ExecFlag
,
utils
.
PreloadJSFlag
}
)
var
(
consoleCommand
=
cli
.
Command
{
Action
:
localConsole
,
Action
:
utils
.
MigrateFlags
(
localConsole
)
,
Name
:
"console"
,
Usage
:
"Start an interactive JavaScript environment"
,
ArgsUsage
:
""
,
// TODO: Write this!
Flags
:
append
(
append
(
nodeFlags
,
rpcFlags
...
),
consoleFlags
...
),
Category
:
"CONSOLE COMMANDS"
,
Description
:
`
The Geth console is an interactive shell for the JavaScript runtime environment
which exposes a node admin interface as well as the Ðapp JavaScript API.
See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Console
`
,
See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Console.`
,
}
attachCommand
=
cli
.
Command
{
Action
:
remoteConsole
,
Action
:
utils
.
MigrateFlags
(
remoteConsole
)
,
Name
:
"attach"
,
Usage
:
"Start an interactive JavaScript environment (connect to node)"
,
ArgsUsage
:
""
,
// TODO: Write this!
ArgsUsage
:
"[endpoint]"
,
Flags
:
append
(
consoleFlags
,
utils
.
DataDirFlag
),
Category
:
"CONSOLE COMMANDS"
,
Description
:
`
The Geth console is an interactive shell for the JavaScript runtime environment
which exposes a node admin interface as well as the Ðapp JavaScript API.
See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Console.
This command allows to open a console on a running geth node.
`
,
This command allows to open a console on a running geth node.`
,
}
javascriptCommand
=
cli
.
Command
{
Action
:
ephemeralConsole
,
Action
:
utils
.
MigrateFlags
(
ephemeralConsole
)
,
Name
:
"js"
,
Usage
:
"Execute the specified JavaScript files"
,
ArgsUsage
:
""
,
// TODO: Write this!
ArgsUsage
:
"<jsfile> [jsfile...]"
,
Flags
:
append
(
nodeFlags
,
consoleFlags
...
),
Category
:
"CONSOLE COMMANDS"
,
Description
:
`
The JavaScript VM exposes a node admin interface as well as the Ðapp
JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Console
`
,
JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Console`
,
}
)
...
...
@@ -81,11 +86,12 @@ func localConsole(ctx *cli.Context) error {
utils
.
Fatalf
(
"Failed to attach to the inproc geth: %v"
,
err
)
}
config
:=
console
.
Config
{
DataDir
:
node
.
DataDir
(),
DataDir
:
utils
.
Make
DataDir
(
ctx
),
DocRoot
:
ctx
.
GlobalString
(
utils
.
JSpathFlag
.
Name
),
Client
:
client
,
Preload
:
utils
.
MakeConsolePreloads
(
ctx
),
}
console
,
err
:=
console
.
New
(
config
)
if
err
!=
nil
{
utils
.
Fatalf
(
"Failed to start the JavaScript console: %v"
,
err
)
...
...
@@ -118,17 +124,18 @@ func remoteConsole(ctx *cli.Context) error {
Client
:
client
,
Preload
:
utils
.
MakeConsolePreloads
(
ctx
),
}
console
,
err
:=
console
.
New
(
config
)
if
err
!=
nil
{
utils
.
Fatalf
(
"Failed to start the JavaScript console: %v"
,
err
)
}
defer
console
.
Stop
(
false
)
// If only a short execution was requested, evaluate and return
if
script
:=
ctx
.
GlobalString
(
utils
.
ExecFlag
.
Name
);
script
!=
""
{
console
.
Evaluate
(
script
)
return
nil
}
// Otherwise print the welcome screen and enter interactive mode
console
.
Welcome
()
console
.
Interactive
()
...
...
@@ -151,7 +158,7 @@ func dialRPC(endpoint string) (*rpc.Client, error) {
}
// ephemeralConsole starts a new geth node, attaches an ephemeral JavaScript
// console to it,
and
each of the files specified as arguments and tears
the
// console to it,
executes
each of the files specified as arguments and tears
// everything down.
func
ephemeralConsole
(
ctx
*
cli
.
Context
)
error
{
// Create and start the node based on the CLI flags
...
...
@@ -165,11 +172,12 @@ func ephemeralConsole(ctx *cli.Context) error {
utils
.
Fatalf
(
"Failed to attach to the inproc geth: %v"
,
err
)
}
config
:=
console
.
Config
{
DataDir
:
node
.
DataDir
(),
DataDir
:
utils
.
Make
DataDir
(
ctx
),
DocRoot
:
ctx
.
GlobalString
(
utils
.
JSpathFlag
.
Name
),
Client
:
client
,
Preload
:
utils
.
MakeConsolePreloads
(
ctx
),
}
console
,
err
:=
console
.
New
(
config
)
if
err
!=
nil
{
utils
.
Fatalf
(
"Failed to start the JavaScript console: %v"
,
err
)
...
...
This diff is collapsed.
Click to expand it.
cmd/geth/main.go
+
51
−
47
View file @
502a2bd6
...
...
@@ -49,39 +49,8 @@ var (
relOracle
=
common
.
HexToAddress
(
"0xfa7b9770ca4cb04296cac84f37736d4041251cdf"
)
// The app that holds all commands and flags.
app
=
utils
.
NewApp
(
gitCommit
,
"the go-ethereum command line interface"
)
)
func
init
()
{
// Initialize the CLI app and start Geth
app
.
Action
=
geth
app
.
HideVersion
=
true
// we have a command to print the version
app
.
Copyright
=
"Copyright 2013-2017 The go-ethereum Authors"
app
.
Commands
=
[]
cli
.
Command
{
// See chaincmd.go:
initCommand
,
importCommand
,
exportCommand
,
removedbCommand
,
dumpCommand
,
// See monitorcmd.go:
monitorCommand
,
// See accountcmd.go:
accountCommand
,
walletCommand
,
// See consolecmd.go:
consoleCommand
,
attachCommand
,
javascriptCommand
,
// See misccmd.go:
makedagCommand
,
versionCommand
,
bugCommand
,
licenseCommand
,
// See config.go
dumpConfigCommand
,
}
app
.
Flags
=
[]
cli
.
Flag
{
// flags that configure the node
nodeFlags
=
[]
cli
.
Flag
{
utils
.
IdentityFlag
,
utils
.
UnlockedAccountFlag
,
utils
.
PasswordFileFlag
,
...
...
@@ -103,7 +72,6 @@ func init() {
utils
.
LightKDFFlag
,
utils
.
CacheFlag
,
utils
.
TrieCacheGenFlag
,
utils
.
JSpathFlag
,
utils
.
ListenPortFlag
,
utils
.
MaxPeersFlag
,
utils
.
MaxPendingPeersFlag
,
...
...
@@ -118,19 +86,6 @@ func init() {
utils
.
NetrestrictFlag
,
utils
.
NodeKeyFileFlag
,
utils
.
NodeKeyHexFlag
,
utils
.
RPCEnabledFlag
,
utils
.
RPCListenAddrFlag
,
utils
.
RPCPortFlag
,
utils
.
RPCApiFlag
,
utils
.
WSEnabledFlag
,
utils
.
WSListenAddrFlag
,
utils
.
WSPortFlag
,
utils
.
WSApiFlag
,
utils
.
WSAllowedOriginsFlag
,
utils
.
IPCDisabledFlag
,
utils
.
IPCPathFlag
,
utils
.
ExecFlag
,
utils
.
PreloadJSFlag
,
utils
.
WhisperEnabledFlag
,
utils
.
DevModeFlag
,
utils
.
TestNetFlag
,
...
...
@@ -146,6 +101,55 @@ func init() {
utils
.
ExtraDataFlag
,
configFileFlag
,
}
rpcFlags
=
[]
cli
.
Flag
{
utils
.
RPCEnabledFlag
,
utils
.
RPCListenAddrFlag
,
utils
.
RPCPortFlag
,
utils
.
RPCApiFlag
,
utils
.
WSEnabledFlag
,
utils
.
WSListenAddrFlag
,
utils
.
WSPortFlag
,
utils
.
WSApiFlag
,
utils
.
WSAllowedOriginsFlag
,
utils
.
IPCDisabledFlag
,
utils
.
IPCPathFlag
,
}
)
func
init
()
{
// Initialize the CLI app and start Geth
app
.
Action
=
geth
app
.
HideVersion
=
true
// we have a command to print the version
app
.
Copyright
=
"Copyright 2013-2017 The go-ethereum Authors"
app
.
Commands
=
[]
cli
.
Command
{
// See chaincmd.go:
initCommand
,
importCommand
,
exportCommand
,
removedbCommand
,
dumpCommand
,
// See monitorcmd.go:
monitorCommand
,
// See accountcmd.go:
accountCommand
,
walletCommand
,
// See consolecmd.go:
consoleCommand
,
attachCommand
,
javascriptCommand
,
// See misccmd.go:
makedagCommand
,
versionCommand
,
bugCommand
,
licenseCommand
,
// See config.go
dumpConfigCommand
,
}
app
.
Flags
=
append
(
app
.
Flags
,
nodeFlags
...
)
app
.
Flags
=
append
(
app
.
Flags
,
rpcFlags
...
)
app
.
Flags
=
append
(
app
.
Flags
,
consoleFlags
...
)
app
.
Flags
=
append
(
app
.
Flags
,
debug
.
Flags
...
)
app
.
Before
=
func
(
ctx
*
cli
.
Context
)
error
{
...
...
This diff is collapsed.
Click to expand it.
cmd/utils/flags.go
+
1
−
1
View file @
502a2bd6
...
...
@@ -331,7 +331,7 @@ var (
}
ExecFlag
=
cli
.
StringFlag
{
Name
:
"exec"
,
Usage
:
"Execute JavaScript statement
(only in combination with console/attach)
"
,
Usage
:
"Execute JavaScript statement"
,
}
PreloadJSFlag
=
cli
.
StringFlag
{
Name
:
"preload"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment