Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
duniter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
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
nodes
typescript
duniter
Commits
b6df78ae
Commit
b6df78ae
authored
8 years ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
[enh] The module API now allows to add CLI options
parent
6c0c915b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/cli.js
+6
-0
6 additions, 0 deletions
app/cli.js
index.js
+3
-0
3 additions, 0 deletions
index.js
with
9 additions
and
0 deletions
app/cli.js
+
6
−
0
View file @
b6df78ae
...
@@ -768,6 +768,7 @@ function service(callback, nologs) {
...
@@ -768,6 +768,7 @@ function service(callback, nologs) {
cbArgs
.
length
--
;
cbArgs
.
length
--
;
cbArgs
[
cbArgs
.
length
++
]
=
server
;
cbArgs
[
cbArgs
.
length
++
]
=
server
;
cbArgs
[
cbArgs
.
length
++
]
=
server
.
conf
;
cbArgs
[
cbArgs
.
length
++
]
=
server
.
conf
;
cbArgs
[
cbArgs
.
length
++
]
=
program
;
onService
&&
onService
(
server
);
onService
&&
onService
(
server
);
return
callback
.
apply
(
that
,
cbArgs
);
return
callback
.
apply
(
that
,
cbArgs
);
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -796,6 +797,11 @@ module.exports.addCommand = (command, requirements, promiseCallback) => {
...
@@ -796,6 +797,11 @@ module.exports.addCommand = (command, requirements, promiseCallback) => {
.
action
(
subCommand
(
service
(
promiseCallback
)));
.
action
(
subCommand
(
service
(
promiseCallback
)));
};
};
module
.
exports
.
addOption
=
(
optFormat
,
optDesc
,
optParser
)
=>
{
program
.
option
(
optFormat
,
optDesc
,
optParser
);
};
function
needsToBeLaunchedByScript
()
{
function
needsToBeLaunchedByScript
()
{
logger
.
error
(
'
This command must not be launched directly, using duniter.sh script
'
);
logger
.
error
(
'
This command must not be launched directly, using duniter.sh script
'
);
return
Promise
.
resolve
();
return
Promise
.
resolve
();
...
...
This diff is collapsed.
Click to expand it.
index.js
+
3
−
0
View file @
b6df78ae
...
@@ -62,6 +62,9 @@ module.exports.statics = {
...
@@ -62,6 +62,9 @@ module.exports.statics = {
const
stack
=
{
const
stack
=
{
registerDependency
:
(
requiredObject
)
=>
{
registerDependency
:
(
requiredObject
)
=>
{
for
(
const
opt
of
(
requiredObject
.
duniter
.
cliOptions
||
[]))
{
cli
.
addOption
(
opt
.
value
,
opt
.
desc
,
opt
.
parser
);
}
for
(
const
command
of
(
requiredObject
.
duniter
.
cli
||
[]))
{
for
(
const
command
of
(
requiredObject
.
duniter
.
cli
||
[]))
{
cli
.
addCommand
({
name
:
command
.
name
,
desc
:
command
.
desc
},
command
.
requires
,
command
.
promiseCallback
);
cli
.
addCommand
({
name
:
command
.
name
,
desc
:
command
.
desc
},
command
.
requires
,
command
.
promiseCallback
);
}
}
...
...
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