Skip to content

Commit 2be5073

Browse files
authored
Merge pull request #71 from ESMCI/fix_test_issue_update_flag
Fix test issue update flag
2 parents 5f05c45 + 9597cc6 commit 2be5073

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

git_fleximod/cli.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
from pathlib import Path
2-
import argparse
2+
import argparse, os, sys
3+
from importlib.resources import files
34
from git_fleximod import utils
45

56
__version__ = "0.9.4"
67

8+
class CustomArgumentParser(argparse.ArgumentParser):
9+
def print_help(self, file=None):
10+
# First print the default help message
11+
super().print_help(file)
12+
13+
# Then append the contents of README.md
14+
candidate_paths = [
15+
os.path.join(sys.prefix, "share", "your-package", "README.md"),
16+
os.path.join(os.path.dirname(__file__), "..", "README.md") # fallback for dev
17+
]
18+
for path in candidate_paths:
19+
if os.path.exists(path):
20+
with open(path) as f:
21+
print( f.read(), file=file)
22+
return
23+
print( "README.md not found.", file=file)
24+
725
def find_root_dir(filename=".gitmodules"):
826
""" finds the highest directory in tree
927
which contains a file called filename """
@@ -32,7 +50,7 @@ def get_parser():
3250
description = """
3351
%(prog)s manages checking out groups of gitsubmodules with additional support for Earth System Models
3452
"""
35-
parser = argparse.ArgumentParser(
53+
parser = CustomArgumentParser(
3654
description=description, formatter_class=argparse.RawDescriptionHelpFormatter
3755
)
3856

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def logger():
3232
"submodule_name": "test_optional",
3333
"status1" : "test_optional MPIserial_2.5.0-3-gd82ce7c is out of sync with .gitmodules MPIserial_2.4.0",
3434
"status2" : "test_optional at tag MPIserial_2.4.0",
35-
"status3" : "test_optional not checked out, out of sync at tag MPIserial_2.5.1, expected tag is MPIserial_2.4.0 (optional)",
35+
"status3" : "test_optional not checked out, out of sync at tag MPIserial_2.5.4, expected tag is MPIserial_2.4.0 (optional)",
3636
"status4" : "test_optional at tag MPIserial_2.4.0",
3737
"gitmodules_content": """
3838
[submodule "test_optional"]
@@ -46,7 +46,7 @@ def logger():
4646
"submodule_name": "test_alwaysoptional",
4747
"status1" : "test_alwaysoptional MPIserial_2.3.0 is out of sync with .gitmodules e5cf35c",
4848
"status2" : "test_alwaysoptional at hash e5cf35c",
49-
"status3" : "out of sync at tag MPIserial_2.5.1, expected tag is e5cf35c",
49+
"status3" : "out of sync at tag MPIserial_2.5.4, expected tag is e5cf35c",
5050
"status4" : "test_alwaysoptional at hash e5cf35c",
5151
"gitmodules_content": """
5252
[submodule "test_alwaysoptional"]

0 commit comments

Comments
 (0)