Skip to content

main ☄︎

Main module for scilaunch.

main ☄︎

main()

Run the main function of scilaunch.

scilaunch should be run via the command line:

scilaunch

Optionally set the output directory with the -o or --out-dir flag. Or just add the output directory without any flags.

scilaunch PARENT/DIR

If no target/output directory is set, the current working directory is used as parent directory for the initialized research project.

Source code in src/scilaunch/main.py
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
def main():
    """
    Run the main function of `scilaunch`.

    `scilaunch` should be run via the command line:

        scilaunch

    Optionally set the output directory with the `-o` or `--out-dir` flag.
    Or just add the output directory without any flags.

        scilaunch PARENT/DIR

    If no target/output directory is set,
    the current working directory is used as parent directory for the initialized research project.
    """
    # Parse arguments
    parser = argparse.ArgumentParser(description="Create a research project structure.")
    parser.add_argument("out", type=str, nargs="?", help="Target parent / output directory", default=Path.cwd())
    parser.add_argument("-o", "--out_dir", type=str, help="Target parent / output directory")
    parser.add_argument("-v", "--verbose", action=argparse.BooleanOptionalAction, default=False, help="verbose output")

    # Extract arguments with flags
    FLAGS, _ = parser.parse_known_args()

    # We use this to allow for both positional and flag arguments (since we just have this one argument)
    if FLAGS.out_dir:
        FLAGS.out = FLAGS.out_dir

    # Create a directory structure for a research project
    create(out_dir=FLAGS.out, verbose=FLAGS.verbose)

    return 0