Skip to content

Conversation

@mzuenni
Copy link
Collaborator

@mzuenni mzuenni commented Sep 27, 2025

Will eventually close #466, which was a follow-up of #166

@mzuenni
Copy link
Collaborator Author

mzuenni commented Sep 27, 2025

For now, redid the work from #166 on top of main. Old todo message from @mpsijm:

I was thinking of something like the following (but I'll need to try this to see how it works out):

  1. In main():
    1. Read command line args (without passing the personal config as default values)
    2. Set initial_cwd = os.getcwd()
    3. cd to to contest directory (this reads --contest and --problem only from the command line, but having them in a personal config file wouldn't make sense anyway 😛)
    4. Read personal config
    5. Call run_parsed_arguments with combined args object
  2. In run_parsed_arguments(args):
    1. if action in ['new_contest', 'new_problem']: check if --contest and/or --problem are set, and throw an error if so (only new_problem --contest would be valid). Then, os.chdir(initial_pwd) and continue with the action
    2. else: continue processing the args as usual

Maybe 2.i should be checked before 1.iv, but that requires a bit more rewriting. I'll experiment with it for a bit 🙂

@mpsijm mpsijm changed the title copy from #166 [tools] Separate changing to contest directory and getting problems list Sep 27, 2025
@mzuenni
Copy link
Collaborator Author

mzuenni commented Sep 28, 2025

@mpsijm is this what you had in mind? ^^'

@mzuenni mzuenni requested a review from mpsijm September 28, 2025 20:45
Copy link
Owner

@RagnarGrootKoerkamp RagnarGrootKoerkamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some small comments but overall LGTM.
Didn't run/test anything myself.

@mzuenni mzuenni merged commit f47c814 into main Oct 10, 2025
6 checks passed
@mzuenni mzuenni deleted the cd-before-reading-personal-config branch October 10, 2025 12:52
Copy link
Collaborator

@mpsijm mpsijm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is definitively cleaner than how it was before, thanks! ❤️ The rewrite of config.args in #473 also helps 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better separate parsing of command-line arguments and changing directory

4 participants