Skip to content

Commit 767bde6

Browse files
committed
CLI polish
1 parent 82f50ea commit 767bde6

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ jobs:
135135
default: true
136136
- name: build environment
137137
run: |
138-
echo "PREFIX=$(brew --prefix)" >> $GITHUB_ENV
139-
echo "PATH=${PREFIX}/opt/python/libexec/bin:${PREFIX}/opt/sqlite/bin:${PATH}" >> $GITHUB_ENV
138+
echo "PATH=$(brew --prefix)/opt/python/libexec/bin:$(brew --prefix)/opt/sqlite/bin:${PATH}" >> $GITHUB_ENV
140139
echo "CFLAGS=-I$(brew --prefix)/include -I$(brew --prefix)/opt/sqlite/include -march=sandybridge" >> $GITHUB_ENV
141140
echo "CXXFLAGS=-I$(brew --prefix)/include -I$(brew --prefix)/opt/sqlite/include -march=sandybridge" >> $GITHUB_ENV
142141
echo "LDFLAGS=-L$(brew --prefix)/lib -L$(brew --prefix)/opt/sqlite/lib" >> $GITHUB_ENV

bindings/python/genomicsqlite/__init__.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ def get_reference_sequences_by_name(
201201
Enters the sqlite3 command-line shell on a GenomicSQLite-compressed database.
202202
203203
sqlite3_ARG: passed through to sqlite3 (see `sqlite3 -help`)
204+
205+
206+
Usage: genomicsqlite DB_FILENAME --compact [options|--help]
207+
[Re]compress and defragment an existing SQLite3 or GenomicSQLite database. See --compact --help for options
204208
"""
205209

206210

@@ -213,7 +217,7 @@ def _cli():
213217
language bindings.
214218
"""
215219

216-
if "--compact" in sys.argv:
220+
if "--compact" in sys.argv or "-compact" in sys.argv:
217221
_compact(sys.argv[1], sys.argv[2:])
218222
return
219223

@@ -226,7 +230,7 @@ def _cli():
226230
or next((True for a in ("-h", "-help", "--help") if a in sys.argv), False)
227231
):
228232
print(
229-
"Usage: genomicsqlite DB_FILENAME ([-readonly] [sqlite3_ARG ...] | --compact ...)",
233+
"Usage: genomicsqlite DB_FILENAME [--readonly] [sqlite3_ARG ...]\n",
230234
file=sys.stderr,
231235
)
232236
print(
@@ -236,6 +240,10 @@ def _cli():
236240
sys.exit(1)
237241

238242
cfg = {}
243+
try:
244+
sys.argv[sys.argv.index("--readonly")] = "-readonly"
245+
except ValueError:
246+
pass
239247
if "-readonly" in sys.argv:
240248
cfg["mode"] = "ro"
241249
cfg = json.dumps(cfg)
@@ -292,7 +300,7 @@ def _compact(dbfilename, argv):
292300
prog="genomicsqlite DB_FILENAME --compact",
293301
description="[Re]compress and defragment an existing SQLite3 or GenomicSQLite database.",
294302
)
295-
parser.add_argument("--compact", action="store_true", help=argparse.SUPPRESS)
303+
parser.add_argument("-compact", "--compact", action="store_true", help=argparse.SUPPRESS)
296304
parser.add_argument(
297305
"-o", dest="out_filename", type=str, help="compacted database path [DB_FILENAME.compact]"
298306
)
@@ -337,7 +345,7 @@ def _compact(dbfilename, argv):
337345

338346
# open db (sniffing whether it's currently compressed or not)
339347
con = None
340-
web = next((True for pfx in ("http:", "https:") if dbfilename.startswith(pfx)), False)
348+
web = dbfilename.startswith("http:") or dbfilename.startswith("https:")
341349
if not web:
342350
con = sqlite3.connect(f"file:{urllib.parse.quote(dbfilename)}?mode=ro", uri=True)
343351
if next(con.execute("PRAGMA application_id"))[0] == 0x7A737464:

0 commit comments

Comments
 (0)