1usage () {
2  cat <<EOF
3Usage: bz search [-a assigned_to] [-c component] [-H hardware] [-p product] [-r reported_by] \\
4                 [-R resolution ] [-s state] [-S severity] [-v version]
5       bz search [-A|-DPB] .....
6       bz search -h
7
8Optional:
9    -H    -- only prs for this hardware
10    -R    -- resolution of pr
11    -S    -- severity of pr
12    -a    -- email address pr is assigned to
13    -c    -- component pr is in
14    -h    -- this help message
15    -p    -- product pr is in
16    -r    -- email address that reported pr
17    -s    -- state of pr
18    -v    -- only prs affecting this version
19
20Shortcuts:
21    -A    -- search all products equivalent to -BDP
22    -B    -- equivalent to -p "Base System"
23    -D    -- equivalent to -p "Documentation"
24    -P    -- equivalent to -p "Ports & Packages"
25
26Defaults may be configured in $HOME/.fbcrc
27Assuming the backend supports it, any option may be a "," seperated list.
28EOF
29
30  exit 1
31}
32
33search () {
34  backend_search "$@"
35}
36
37. ${BZ_SCRIPTDIR}/_util.sh
38. ${BZ_BACKENDDIR}/search.sh
39
40assigned_to=
41component=
42hardware=
43product=
44reporter=
45resolution=
46state=
47severity=
48version=
49
50## Load default search criteria
51. $HOME/.fbcrc
52
53[ $# -lt 1 ] && product="Base System,Documentation,Ports & Packages"
54
55while getopts ABDPH:R:S:a:c:hp:r:s:v: FLAG; do
56  case ${FLAG} in
57    A) product="Base System,Documentation,Ports & Packages" ;;
58    B) product="Base System" ;;
59    D) product="Documentation" ;;
60    P) product="Ports & Packages" ;;
61    H) hardware="$OPTARG"    ;;
62    R) resolution="$OPTARG"  ;;
63    S) severity="$OPTARG"    ;;
64    a) assigned_to="$OPTARG" ;;
65    c) component="$OPTARG"   ;;
66    p) product="$OPTARG"     ;;
67    r) reporter="$OPTARG"    ;;
68    s) state="$OPTARG"       ;;
69    v) version="$OPTARG"     ;;
70    h|*) usage               ;;
71  esac
72done
73shift $(($OPTIND-1))
74
75search "$assigned_to" "$component" "$hardware" "$product" \
76  "$reporter" "$resolution" "$state" "$severity" "$version"
77