Skip to content

Commit 6db4b9d

Browse files
committed
[new_problem] Correctly read source from args.contest
Related to RagnarGrootKoerkamp#166: this bug existed because new_problem did not change directory to args.contest.
1 parent 25e45f8 commit 6db4b9d

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

bin/skel.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def get_skel_dir(target_dir):
131131
def new_problem():
132132
target_dir = Path(".")
133133
if config.args.contest:
134-
target_dir = Path(config.args.contest)
134+
os.chdir(Path(config.args.contest))
135135
if config.args.problem:
136136
fatal("--problem does not work for new_problem.")
137137

@@ -189,12 +189,14 @@ def new_problem():
189189
}.items():
190190
variables[k] = v
191191

192-
variables["source"] = _ask_variable_string(
192+
source_name = _ask_variable_string(
193193
"source", variables.get("source", variables.get("name", "")), True
194194
)
195-
variables["source_url"] = _ask_variable_string(
196-
"source url", variables.get("source_url", ""), True
195+
source_url = _ask_variable_string("source url", variables.get("source_url", ""), True)
196+
variables["source"] = (
197+
f"source:\n name: {source_name}\n{' url: {source_url}' if source_url else ' #url:'}"
197198
)
199+
198200
variables["license"] = _ask_variable_choice(
199201
"license", config.KNOWN_LICENSES, variables.get("license", None)
200202
)

skel/problem/problem.yaml

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ name:
77
# 'pass-fail', 'interactive', 'multi-pass', or 'interactive multi-pass'
88
uuid: {%uuid%}
99
credits: {%author%}
10-
source:
11-
name: {%source%}
12-
url: {%source_url%}
10+
{%source%}
1311
license: {%license%}
1412
rights_owner: {%rights_owner%}
1513

0 commit comments

Comments
 (0)