Skip to content

Commit 4e4dc32

Browse files
committed
Fix argument parsing & bump version
1 parent 93f8f31 commit 4e4dc32

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

TODOLIST.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
- [x] Download compressed testdata
33
- [x] User-specified compilation flags (special judge / user program)
44
- [ ] SIGINT waits for current judge queue to complete
5+
- [ ] Kattis / Polygon / CMS(?)-style special judge
56
- [ ] Pin judge (platform-independent judge result)
67
- [ ] I/O Interactive (TODO FEATURE(io-interactive))
78
- I/O interactive should also support multistage (similar to that of CMS Communication)

src/main.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ void ParseConfig(const fs::path& conf_path) {
4949

5050
void ParseArgs(int argc, char** argv) {
5151
int verbosity = 0;
52-
argparse::ArgumentParser parser(argc ? argv[0] : "tioj-judge");
52+
argparse::ArgumentParser parser(
53+
argc ? argv[0] : "tioj-judge", kVersionCode, argparse::default_arguments::help);
54+
parser.add_argument("--version")
55+
.default_value(false)
56+
.implicit_value(true)
57+
.help("Show version and exit");
5358
parser.add_argument("-c", "--config")
5459
.required().default_value(std::string("/etc/tioj-judge.conf"))
5560
.help("Path of configuration file");
@@ -78,6 +83,10 @@ void ParseArgs(int argc, char** argv) {
7883
exit(1);
7984
}
8085

86+
if (parser["--version"] == true) {
87+
std::cout << kVersionCode << std::endl;
88+
exit(0);
89+
}
8190
switch (verbosity) {
8291
case 0: spdlog::set_level(spdlog::level::warn); break;
8392
case 1: spdlog::set_level(spdlog::level::info); break;
@@ -127,11 +136,11 @@ bool LockFile() {
127136
int main(int argc, char** argv) {
128137
spdlog::set_pattern("[%t] %+");
129138
InitLogger();
139+
ParseArgs(argc, argv);
130140
if (geteuid() != 0) {
131141
spdlog::error("Must be run as root.");
132142
return 1;
133143
}
134-
ParseArgs(argc, argv);
135144
if (to_lock && !LockFile()) {
136145
spdlog::error("Another judge instance is running.");
137146
return 1;

src/server_io.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <string>
55
#include "tioj/submission.h"
66

7-
const std::string kVersionCode = "2.1.2";
7+
const std::string kVersionCode = "2.1.3";
88
extern std::string kTIOJUrl;
99
extern std::string kTIOJKey;
1010
extern size_t kMaxQueue;

0 commit comments

Comments
 (0)