@@ -1071,7 +1071,7 @@ function cleanup()
1071
1071
invalidSubCommand cleanup STATUS ${OPTARG}
1072
1072
fi
1073
1073
1074
- st=${ OPTARG}
1074
+ st=" ${st} ${ OPTARG}"
1075
1075
;;
1076
1076
* )
1077
1077
invalidSubCommand cleanup flag ${OPTARG}
@@ -1086,47 +1086,52 @@ function cleanup()
1086
1086
fi
1087
1087
1088
1088
# Get all states if we don't specify one:
1089
- if [[ ${# st} -eq 0 ]] ; then
1089
+ if [[ ${# st} -eq 0 ]] ; then
1090
1090
st=${TERMINAL_STATES}
1091
1091
fi
1092
1092
1093
1093
# Display the logo:
1094
1094
turtle
1095
+ echo
1096
+
1097
+ # Remove the lines:
1098
+ local tmpFile=$( makeTemp )
1099
+ local tmpFile_remove=$( makeTemp )
1095
1100
1096
- echo
1097
- echo " State(s) selected: ${st} "
1101
+ echo " I'm looking for records with the following states: ${st} "
1098
1102
echo
1103
+ while read line ; do
1104
+ for s in ${st} ; do
1105
+ # Go through each line and filter by status, which is the last column:
1106
+ lineStatus=$( echo $line | awk ' {print $NF}' )
1107
+ if [[ " ${lineStatus} " == " ${s} " ]] ; then
1108
+ echo $line >> ${tmpFile_remove}
1109
+ continue 2
1110
+ fi
1111
+ done
1112
+ echo $line >> ${tmpFile}
1113
+ done < ${CROMWELL_SUBMISSIONS_FILE}
1114
+
1115
+ echo " The following records are about to be removed:"
1116
+ echo
1117
+
1118
+ cat ${tmpFile_remove} | column -t
1119
+
1120
+ echo
1121
+ getAnswerFromUser " Are you sure you want to CLEAR the listed records? " ' Yes No' answer
1099
1122
1100
- getAnswerFromUser " Are you sure you want to CLEAR ALL RECORDS from these states: ${st} " ' Yes No' answer
1101
-
1102
1123
if [[ $( echo " ${answer} " | tr A-Z a-z ) == " yes" ]] ; then
1103
1124
echo " User answered 'Yes'."
1104
1125
echo
1105
1126
1106
1127
# Backup the file:
1107
1128
echo " Creating backup of records file:"
1108
1129
cp -v ${CROMWELL_SUBMISSIONS_FILE} ${CROMWELL_SUBMISSIONS_FILE} .$( date +%Y%m%dT%H%M%S ) .bak
1109
- echo
1110
-
1111
- # Remove the lines:
1112
- local tmpFile=$( makeTemp )
1113
- for s in ${st} ; do
1114
- echo -n " Removing records with state: ${s} "
1115
-
1116
- # Go through each line and filter by status, which is the last column:
1117
- while read line ; do
1118
- lineStatus=$( echo $line | awk ' {print $NF}' )
1119
- if [[ " ${lineStatus} " != " ${s} " ]] ; then
1120
- echo $line
1121
- fi
1122
- done < ${CROMWELL_SUBMISSIONS_FILE} > ${tmpFile}
1123
-
1124
- # Copy the temp file to the final file location for the next
1125
- # iteration or for when we're done
1126
- cp ${tmpFile} ${CROMWELL_SUBMISSIONS_FILE}
1130
+ echo
1127
1131
1128
- echo -e ' \t\tDONE!'
1129
- done
1132
+ # Copy the temp file to the final file location for the next
1133
+ # iteration or for when we're done
1134
+ cp ${tmpFile} ${CROMWELL_SUBMISSIONS_FILE}
1130
1135
1131
1136
echo ' Your cromshell logs are now clean.'
1132
1137
return 0
@@ -1136,6 +1141,7 @@ function cleanup()
1136
1141
fi
1137
1142
}
1138
1143
1144
+
1139
1145
function assertDialogExists()
1140
1146
{
1141
1147
which dialog & > /dev/null
0 commit comments