Skip to content
Snippets Groups Projects
Commit c5616c6f authored by Eliott Sammier's avatar Eliott Sammier
Browse files

More CLI fixes

parent a6d710f1
No related branches found
No related tags found
1 merge request!5Resolve "Parseur par type d'activité"
...@@ -2,17 +2,23 @@ ...@@ -2,17 +2,23 @@
# Default value for version env var # Default value for version env var
if [[ -z "$VERSION" ]]; then if [[ -z "$VERSION" ]]; then
VERSION="each" VERSION="macao_12"
fi fi
# First parameter overrides version if set # First parameter overrides version if set
version_regex='^(macao_12|macao_3|each|full)$'
if [[ "$1" == "12" || "$1" == "3" ]]; then if [[ "$1" == "12" || "$1" == "3" ]]; then
VERSION="macao_$1" VERSION="macao_$1"
shift shift
elif [[ "$1" = "each" || "$1" = "full" ]]; then elif [[ "$1" =~ $version_regex ]]; then
VERSION="$1" VERSION="$1"
shift shift
fi fi
export VERSION export VERSION
if [[ ! "$VERSION" =~ $version_regex ]]; then
echo "Invalid version '$VERSION'"
exit 1
fi
# Special version value "each" is processed by calling the script itself once # Special version value "each" is processed by calling the script itself once
# for each actual version # for each actual version
if [[ "$VERSION" = "each" && "$1" != "shell" && "$1" != "status" && "$1" != "setup" ]]; then if [[ "$VERSION" = "each" && "$1" != "shell" && "$1" != "status" && "$1" != "setup" ]]; then
...@@ -35,8 +41,14 @@ print_usage() { ...@@ -35,8 +41,14 @@ print_usage() {
cat <<EOF cat <<EOF
Usage: $(basename "$0") [version] <command> [args] Usage: $(basename "$0") [version] <command> [args]
COMMANDS VERSION
Specifies which part of the MACAO repository to use: "macao_12", "macao_3"
(or simply "12" and "3"), "each" for both in separate result dirs
and "full" for both merged in a single result dir.
If not specified, uses the value of the "VERSION" environment variable,
or "12" by default. Some commands do not support every version.
COMMANDS
status status
Print useful info about the current environment. Print useful info about the current environment.
shell [-p|--pyenv] shell [-p|--pyenv]
...@@ -50,7 +62,8 @@ index-extensions ...@@ -50,7 +62,8 @@ index-extensions
Index all files by extension Index all files by extension
count-all [-f|--force] count-all [-f|--force]
Count many types of Macao objects. Count many types of Macao objects.
If -f or --force is given, refresh indexes before counting (equivalent to count-streams and index-extensions) If -f or --force is given, refresh indexes before counting (equivalent
to count-streams and index-extensions)
setup setup
Initialize Python environment required by extractors Initialize Python environment required by extractors
setup-debug setup-debug
...@@ -131,6 +144,7 @@ index_extensions() { ...@@ -131,6 +144,7 @@ index_extensions() {
allfiles="$(find . -path '**/.idea' -prune -o -type f -print)" allfiles="$(find . -path '**/.idea' -prune -o -type f -print)"
cd - || exit cd - || exit
# List all extensions, then for each one, filter the index for files with this extension # List all extensions, then for each one, filter the index for files with this extension
# ( Perl expression courtesy of https://stackoverflow.com/a/1842270 )
perl -ne 'print $1 if m/\.([^.\/]+)$/**//' <<<"$allfiles" | sort -u | while read -r ext; do perl -ne 'print $1 if m/\.([^.\/]+)$/**//' <<<"$allfiles" | sort -u | while read -r ext; do
echo "[$ext]" >>"$out_file" echo "[$ext]" >>"$out_file"
grep -E ".*\.$ext\$" <<<"$allfiles" | sort >>"$out_file" grep -E ".*\.$ext\$" <<<"$allfiles" | sort >>"$out_file"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment