File: pgdoc

package info (click to toggle)
surfraw 2.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,624 kB
  • sloc: sh: 7,977; perl: 824; makefile: 277
file content (85 lines) | stat: -rwxr-xr-x 2,176 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/sh
# ianb@erislabs.net 20130923
# elvis: pgdoc		-- Search postgres documentation (www.pgdoc.com)
. surfraw || exit 1

w3_config_hook () {
    def   SURFRAW_pgdoc_version 9.1
    defyn SURFRAW_pgdoc_comments no
}

w3_usage_hook () {
    cat <<EOF
Usage: $w3_argv0 [options] [search words]...
Description:
  Surfraw search the Postgresql documentation (www.postgresql.org)
Local options:
  -c                            Search in comments too
  -v=VERSION                    Search in version VERSION
                                Default: $SURFRAW_pgdoc_version
                                Environment: SURFRAW_pgdoc_version
EOF
    w3_custom_search_usage
    w3_global_usage
}

w3_parse_option_hook () {
    opt="$1"
    optarg="$2"
    case "$opt" in
    -c*)        setoptyn SURFRAW_pgdoc_comments  1  ;;
    -v*=*)      setopt   SURFRAW_pgdoc_version   "$optarg" ;;
    *) return 1 ;;
    esac
    return 0
}

w3_config
w3_parse_args "$@"

if test -z "$w3_args"
then
    case "$SURFRAW_pgdoc_version" in
        all)    inurl="/docs/"       ;;
        *9.3*)  inurl="/docs/9.3/"   ;;
        *9.2*)  inurl="/docs/9.2/"   ;;
        *9.1*)  inurl="/docs/9.1/"   ;;
        *9.0*)  inurl="/docs/9.0/"   ;;
        *8.4*)  inurl="/docs/8.4/"   ;;
        *)      inurl="/docs/"       ;;
    esac

    if  [ "$SURFRAW_pgdoc_version" != all ]
    then
        if ifyes SURFRAW_pgdoc_comments
    then
            inurl="${inurl}interactive/"
        else
            inurl="${inurl}static/"
        fi
    fi
    w3_browse_url "https://www.postgresql.org${inurl}"

else

    case "$SURFRAW_pgdoc_version" in
        all)    inurl="-u=docs"        ;;
        *9.3*)  inurl="-u=docs -u=9.3" ;;
        *9.2*)  inurl="-u=docs -u=9.2" ;;
        *9.1*)  inurl="-u=docs -u=9.1" ;;
        *9.0*)  inurl="-u=docs -u=9.0" ;;
        *8.4*)  inurl="-u=docs -u=8.4" ;;
        *)      inurl="-u=docs"        ;;
esac

if  [ "$SURFRAW_pgdoc_version" != all ]
then
    if ifyes SURFRAW_pgdoc_comments
    then
        inurl="${inurl} -u=interactive"
    else
        inurl="${inurl} -u=static"
    fi
fi
    w3_custom_search -s=www.postgresql.org $inurl "$w3_shquoted_args"
fi