bam ls, add --full option to return full paths
This commit is contained in:
14
bam/cli.py
14
bam/cli.py
@@ -1225,7 +1225,7 @@ class bam_commands:
|
|||||||
print(json.dumps(ret))
|
print(json.dumps(ret))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def list_dir(paths, use_json=False):
|
def list_dir(paths, use_full=False, use_json=False):
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
# Load project configuration
|
# Load project configuration
|
||||||
@@ -1259,12 +1259,15 @@ class bam_commands:
|
|||||||
|
|
||||||
print(json.dumps(ret))
|
print(json.dumps(ret))
|
||||||
else:
|
else:
|
||||||
|
def strip_dot_slash(f):
|
||||||
|
return f[2:] if f.startswith("./") else f
|
||||||
|
|
||||||
for (name_short, name_full, file_type) in items:
|
for (name_short, name_full, file_type) in items:
|
||||||
if file_type == "dir":
|
if file_type == "dir":
|
||||||
print(" %s/" % name_short)
|
print(" %s/" % (strip_dot_slash(name_full) if use_full else name_short))
|
||||||
for (name_short, name_full, file_type) in items:
|
for (name_short, name_full, file_type) in items:
|
||||||
if file_type != "dir":
|
if file_type != "dir":
|
||||||
print(" %s" % name_short)
|
print(" %s" % (strip_dot_slash(name_full) if use_full else name_short))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def deps(paths, recursive=False, use_json=False):
|
def deps(paths, recursive=False, use_json=False):
|
||||||
@@ -1582,6 +1585,10 @@ def create_argparse_list(subparsers):
|
|||||||
dest="paths", nargs="*",
|
dest="paths", nargs="*",
|
||||||
help="Path(s) to operate on",
|
help="Path(s) to operate on",
|
||||||
)
|
)
|
||||||
|
subparse.add_argument(
|
||||||
|
"-f", "--full", dest="full", action='store_true',
|
||||||
|
help="Show the full paths",
|
||||||
|
)
|
||||||
|
|
||||||
init_argparse_common(subparse, use_json=True)
|
init_argparse_common(subparse, use_json=True)
|
||||||
|
|
||||||
@@ -1589,6 +1596,7 @@ def create_argparse_list(subparsers):
|
|||||||
func=lambda args:
|
func=lambda args:
|
||||||
bam_commands.list_dir(
|
bam_commands.list_dir(
|
||||||
args.paths or ["."],
|
args.paths or ["."],
|
||||||
|
use_full=args.full,
|
||||||
use_json=args.json,
|
use_json=args.json,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user