-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.js
113 lines (96 loc) · 2.3 KB
/
commands.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/usr/bin/env node
const program = require('commander');
const { prompt } = require('inquirer');
const {Var} = require("./models/Var.js");
// Authentication questions
const authQs=[
{
type: "input",
name: "username",
message: "Username"
},
{
type: "password",
name: "password",
message: "Password"
}
]
const {
showCourses,
LogIn,
Logout,
getCourses,
getAssignments,
getInfo,
getGrades,
Download,
Upload,
} = require('./Functions.js');
program
.version("1.0.0")
.alias("v")
.description("Float Moodle CLI")
program
.command("list courses")
.alias('sc')
.description("Lists out all the courses")
.action(()=>{
showCourses();
});
program
.command("Login")
.alias("li")
.description("To login")
.action(()=>{
prompt(authQs).then(answers=>LogIn(answers));
})
program
.command("Logout")
.alias("lo")
.description("To logout")
.action(()=>{
Logout();
})
program
.command("getCourses")
.alias("gc")
.description("Prints the courses in which you are enrolled")
.action(()=>{
getCourses();
})
program
.command("getAssignments <courseName>")
.alias("ga")
.description("Prints the assignments present in a course")
.action(courseName=>{
getAssignments(courseName);
})
program
.command("getAssignmentInfo <courseName> <assName>")
.alias("gi")
.description("Prints the assignment details")
.action((courseName,assName)=>{
getInfo(courseName,assName);
})
program
.command("getGrades <courseName> <assName>")
.alias("gg")
.description("Prints the grade in an assignment")
.action((courseName,assName)=>{
getGrades(courseName,assName);
})
program
.command("downloadAssignment <courseName> <assName>")
.alias("da")
.description("Downloads the problem statement of an assignment")
.action((courseName,assName)=>{
Download(courseName,assName);
})
program
.command("uploadSolution <courseName> <assName> <absolute_path>")
.alias("u")
.description("Uploads your solution for an assignment")
.action((courseName,assName,path)=>{
Upload(courseName,assName,path);
})
program.parse(process.argv)