Standardize matching test files structure, add test_main.py and test_commands.py, and update GEMINI.md
This commit is contained in:
@@ -1,22 +1,47 @@
|
||||
# functions for commands needed
|
||||
# src/commands.py
|
||||
# from pathlib import path
|
||||
import click
|
||||
from pathlib import Path
|
||||
|
||||
# {{{ basic_group
|
||||
# This defines a group with name basic which will nest other comands to be imported in the main loop
|
||||
@click.group(name="basic")
|
||||
def basic_group(): pass
|
||||
# }}}
|
||||
|
||||
# Adds a simple commmand to be run with `ctf test` per the function name
|
||||
@click.command()
|
||||
# {{{ test
|
||||
# Adds a simple commmand to be run with `ctf basic test`
|
||||
@basic_group.command(name="test")
|
||||
def test():
|
||||
print("hello from test")
|
||||
# }}}
|
||||
|
||||
# {{{ greet
|
||||
# A simple command with a positional(required) argument name
|
||||
@click.command()
|
||||
@basic_group.command(name="greet")
|
||||
@click.argument('name')
|
||||
def greet(name):
|
||||
print(f"hello {name}")
|
||||
# }}}
|
||||
|
||||
# {{{ set_flag_format
|
||||
# Sets the flag format for the current competition in config.toml
|
||||
@basic_group.command(name="set-flag-format")
|
||||
@click.argument("pattern")
|
||||
def set_flag_format(pattern: str):
|
||||
"""Set the flag regex format for the active competition."""
|
||||
from ctf.utils import load_config, write_config
|
||||
|
||||
config_path = "/home/venus/code/ctf/config.toml"
|
||||
config = load_config(config_path)
|
||||
|
||||
if "Competition" not in config:
|
||||
config["Competition"] = {}
|
||||
|
||||
config["Competition"]["flag_format"] = pattern
|
||||
write_config(config, config_path)
|
||||
click.echo(f"Flag format set to: {pattern}")
|
||||
# }}}
|
||||
|
||||
# def Set_Challenge(comp: str, chal: str, setDirectory: bool):
|
||||
# # set the current challenge and competition from input
|
||||
@@ -24,11 +49,9 @@ def greet(name):
|
||||
# state.current_comp=comp
|
||||
# state.comp_dir=pathlib
|
||||
# # TODO archive the old competitions
|
||||
|
||||
#
|
||||
# if state.current_chal != chal:
|
||||
# state.current_chal=chal
|
||||
# print("challenge already set")
|
||||
# # TODO archive the old challenges
|
||||
# # TODO set the directory to challenge directory, with ignore option
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user