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
Commits
e8b09ae3
Commit
e8b09ae3
authored
2 months ago
by
michael.minelli
Browse files
Options
Downloads
Patches
Plain Diff
ExerciseInfoCommand => Add command to get info of an exercise
parent
39cac1b0
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
NodeApp/src/commander/exercise/ExerciseCommand.ts
+3
-3
3 additions, 3 deletions
NodeApp/src/commander/exercise/ExerciseCommand.ts
NodeApp/src/commander/exercise/subcommands/ExerciseInfoCommand.ts
+54
-0
54 additions, 0 deletions
...src/commander/exercise/subcommands/ExerciseInfoCommand.ts
with
57 additions
and
3 deletions
NodeApp/src/commander/exercise/ExerciseCommand.ts
+
3
−
3
View file @
e8b09ae3
...
@@ -3,8 +3,8 @@ import ExerciseCreateCommand from './subcommands/ExerciseCreateCommand.js';
...
@@ -3,8 +3,8 @@ import ExerciseCreateCommand from './subcommands/ExerciseCreateCommand.js';
import
ExerciseRunCommand
from
'
./subcommands/ExerciseRunCommand.js
'
;
import
ExerciseRunCommand
from
'
./subcommands/ExerciseRunCommand.js
'
;
import
ExerciseCorrectionCommand
from
'
./subcommands/ExerciseCorrectionCommand.js
'
;
import
ExerciseCorrectionCommand
from
'
./subcommands/ExerciseCorrectionCommand.js
'
;
import
ExerciseDeleteCommand
from
'
./subcommands/ExerciseDeleteCommand
'
;
import
ExerciseDeleteCommand
from
'
./subcommands/ExerciseDeleteCommand
'
;
import
Exercise
List
Command
from
"
./subcommands/Exercise
List
Command
"
;
import
Exercise
Search
Command
from
'
./subcommands/Exercise
Search
Command
'
;
import
Exercise
Result
Command
from
"
./subcommands/Exercise
Result
Command
"
;
import
Exercise
Info
Command
from
'
./subcommands/Exercise
Info
Command
'
;
import
ExerciseSummaryCommand
from
"
./subcommands/ExerciseSummaryCommand
"
;
import
ExerciseSummaryCommand
from
"
./subcommands/ExerciseSummaryCommand
"
;
...
@@ -22,7 +22,7 @@ class ExerciseCommand extends CommanderCommand {
...
@@ -22,7 +22,7 @@ class ExerciseCommand extends CommanderCommand {
ExerciseDeleteCommand
.
registerOnCommand
(
this
.
command
);
ExerciseDeleteCommand
.
registerOnCommand
(
this
.
command
);
ExerciseCorrectionCommand
.
registerOnCommand
(
this
.
command
);
ExerciseCorrectionCommand
.
registerOnCommand
(
this
.
command
);
ExerciseListCommand
.
registerOnCommand
(
this
.
command
);
ExerciseListCommand
.
registerOnCommand
(
this
.
command
);
Exercise
Result
Command
.
registerOnCommand
(
this
.
command
);
Exercise
Info
Command
.
registerOnCommand
(
this
.
command
);
ExerciseSummaryCommand
.
registerOnCommand
(
this
.
command
);
ExerciseSummaryCommand
.
registerOnCommand
(
this
.
command
);
}
}
...
...
This diff is collapsed.
Click to expand it.
NodeApp/src/commander/exercise/subcommands/ExerciseInfoCommand.ts
0 → 100644
+
54
−
0
View file @
e8b09ae3
import
CommanderCommand
from
'
../../CommanderCommand
'
;
import
AccessesHelper
from
'
../../../helpers/AccessesHelper
'
;
import
TextStyle
from
'
../../../types/TextStyle
'
;
import
ExerciseHelper
from
'
../../../helpers/Dojo/ExerciseHelper
'
;
import
Exercise
from
'
../../../sharedByClients/models/Exercise
'
;
import
DojoBackendManager
from
'
../../../managers/DojoBackendManager
'
;
import
ora
from
'
ora
'
;
import
Config
from
'
../../../config/Config
'
;
class
ExerciseInfoCommand
extends
CommanderCommand
{
protected
commandName
:
string
=
'
info
'
;
protected
defineCommand
():
void
{
this
.
command
.
description
(
'
delete an exercise
'
)
.
argument
(
'
id or url
'
,
'
id or url of the exercise
'
)
.
action
(
this
.
commandAction
.
bind
(
this
));
}
private
async
dataRetrieval
(
exerciseIdOrUrl
:
string
):
Promise
<
Exercise
>
{
console
.
log
(
TextStyle
.
BLOCK
(
'
Please wait while we verify and retrieve data...
'
));
await
AccessesHelper
.
checkStudent
();
// Fetch exercise
const
exercisesGetSpinner
:
ora
.
Ora
=
ora
({
text
:
`Checking exercise`
,
indent
:
4
}).
start
();
const
exercise
=
await
DojoBackendManager
.
getExercise
(
exerciseIdOrUrl
);
if
(
!
exercise
)
{
exercisesGetSpinner
.
fail
(
`Exercise not found`
);
throw
new
Error
();
}
exercisesGetSpinner
.
succeed
(
`Exercise fetched successfully`
);
return
exercise
;
}
protected
async
commandAction
(
exerciseIdOrUrl
:
string
):
Promise
<
void
>
{
try
{
const
exercise
=
await
this
.
dataRetrieval
(
exerciseIdOrUrl
);
return
ExerciseHelper
.
displayDetails
(
exercise
,
Config
.
interactiveMode
);
}
catch
(
e
)
{
/* Do nothing */
}
}
}
export
default
new
ExerciseInfoCommand
();
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