Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DojoCLI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dojo Project (HES-SO)
Projects
UI
DojoCLI
Merge requests
!8
Draft: Resolve "Add bash completion helper function"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Closed
Draft: Resolve "Add bash completion helper function"
3-add-bash-completion-helper-function
into
main
Overview
21
Commits
18
Pipelines
35
Changes
1
Closed
orestis.malaspin
requested to merge
3-add-bash-completion-helper-function
into
main
1 year ago
Overview
21
Commits
18
Pipelines
35
Changes
1
Expand
Closes
#3 (closed)
0
0
Merge request reports
Viewing commit
bd773bb2
Prev
Next
Show latest version
1 file
+
42
−
43
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Verified
bd773bb2
module instead of class
· bd773bb2
orestis.malaspin
authored
1 year ago
NodeApp/src/commander/CommanderApp.ts
+
42
−
43
Options
import
{
Command
,
Option
}
from
'
commander
'
;
import
SessionCommand
from
'
./session/SessionCommand
'
;
import
SessionCommand
from
'
./session/SessionCommand
'
;
import
ClientsSharedConfig
from
'
../sharedByClients/config/ClientsSharedConfig
'
;
import
AssignmentCommand
from
'
./assignment/AssignmentCommand
'
;
import
ExerciseCommand
from
'
./exercise/ExerciseCommand
'
;
import
SharedConfig
from
'
../shared/config/SharedConfig
'
;
import
boxen
from
'
boxen
'
;
import
AssignmentCommand
from
'
./assignment/AssignmentCommand
'
;
import
ExerciseCommand
from
'
./exercise/ExerciseCommand
'
;
import
SharedConfig
from
'
../shared/config/SharedConfig
'
;
import
boxen
from
'
boxen
'
;
import
{
stateConfigFile
}
from
'
../config/ConfigFiles
'
;
import
semver
from
'
semver/preload
'
;
import
{
version
}
from
'
../config/Version
'
;
import
Config
from
'
../config/Config
'
;
import
{
getBashCompletion
}
from
'
../helpers/AutoCompletionHelper
'
;
import
semver
from
'
semver/preload
'
;
import
{
version
}
from
'
../config/Version
'
;
import
Config
from
'
../config/Config
'
;
import
{
getBashCompletion
}
from
'
../helpers/AutoCompletionHelper
'
;
class
CommanderApp
{
@@ -17,22 +17,22 @@ class CommanderApp {
constructor
()
{
this
.
program
.
name
(
'
dojo
'
)
.
description
(
'
CLI of the Dojo application
'
)
.
version
(
'
{{VERSION}}
'
)
.
showHelpAfterError
()
.
configureHelp
({
showGlobalOptions
:
true
,
sortOptions
:
true
,
sortSubcommands
:
true
})
.
option
(
'
-H, --host <string>
'
,
'
override the Dojo API endpoint
'
,
ClientsSharedConfig
.
apiURL
)
.
addOption
(
new
Option
(
'
--debug
'
).
hideHelp
())
.
hook
(
'
preAction
'
,
()
=>
{
this
.
warnDevelopmentVersion
();
}).
hook
(
'
postAction
'
,
()
=>
{
this
.
informNewVersion
();
});
.
name
(
'
dojo
'
)
.
description
(
'
CLI of the Dojo application
'
)
.
version
(
'
{{VERSION}}
'
)
.
showHelpAfterError
()
.
configureHelp
({
showGlobalOptions
:
true
,
sortOptions
:
true
,
sortSubcommands
:
true
})
.
option
(
'
-H, --host <string>
'
,
'
override the Dojo API endpoint
'
,
ClientsSharedConfig
.
apiURL
)
.
addOption
(
new
Option
(
'
--debug
'
).
hideHelp
())
.
hook
(
'
preAction
'
,
()
=>
{
this
.
warnDevelopmentVersion
();
}).
hook
(
'
postAction
'
,
()
=>
{
this
.
informNewVersion
();
});
this
.
program
.
on
(
'
option:host
'
,
()
=>
{
ClientsSharedConfig
.
apiURL
=
this
.
program
.
opts
().
host
;
@@ -45,42 +45,41 @@ class CommanderApp {
this
.
registerCommands
();
getBashCompletion
(
this
.
program
)
// AutoCompletionHelper.getCommands(this.program)
this
.
program
.
parse
();
}
private
warnDevelopmentVersion
()
{
if
(
!
SharedConfig
.
production
)
{
if
(
!
SharedConfig
.
production
)
{
console
.
log
(
boxen
(
`This is a development (unstable) version of the DojoCLI.
If you want to use the stable version, please install the package from the following url:
https://gitedu.hesge.ch/dojo_project/projects/ui/dojocli/-/releases/Latest`
,
{
title
:
'
Warning
'
,
title
:
'
Warning
'
,
titleAlignment
:
'
center
'
,
borderColor
:
'
red
'
,
borderStyle
:
'
bold
'
,
margin
:
1
,
padding
:
1
,
textAlignment
:
'
left
'
borderColor
:
'
red
'
,
borderStyle
:
'
bold
'
,
margin
:
1
,
padding
:
1
,
textAlignment
:
'
left
'
}));
}
}
private
informNewVersion
()
{
if
(
SharedConfig
.
production
)
{
if
(
SharedConfig
.
production
)
{
const
latestDojoCliVersion
=
stateConfigFile
.
getParam
(
'
latestDojoCliVersion
'
)
as
string
|
null
||
'
0.0.0
'
;
const
latestDojoCliVersionNotification
=
stateConfigFile
.
getParam
(
'
latestDojoCliVersionNotification
'
)
as
number
|
null
||
0
;
if
(
semver
.
lt
(
version
,
latestDojoCliVersion
)
)
{
if
(
(
new
Date
()).
getTime
()
-
latestDojoCliVersionNotification
>=
Config
.
versionUpdateInformationPeriodHours
*
60
*
60
*
1000
)
{
console
.
log
(
boxen
(
`The
${
latestDojoCliVersion
}
version of the DojoCLI is available:
if
(
semver
.
lt
(
version
,
latestDojoCliVersion
))
{
if
((
new
Date
()).
getTime
()
-
latestDojoCliVersionNotification
>=
Config
.
versionUpdateInformationPeriodHours
*
60
*
60
*
1000
)
{
console
.
log
(
boxen
(
`The
${
latestDojoCliVersion
}
version of the DojoCLI is available:
https://gitedu.hesge.ch/dojo_project/projects/ui/dojocli/-/releases/Latest`
,
{
title
:
'
Information
'
,
title
:
'
Information
'
,
titleAlignment
:
'
center
'
,
borderColor
:
'
blue
'
,
borderStyle
:
'
bold
'
,
margin
:
1
,
padding
:
1
,
textAlignment
:
'
left
'
borderColor
:
'
blue
'
,
borderStyle
:
'
bold
'
,
margin
:
1
,
padding
:
1
,
textAlignment
:
'
left
'
}));
stateConfigFile
.
setParam
(
'
latestDojoCliVersionNotification
'
,
(
new
Date
()).
getTime
());
}
Loading