You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nutch.apache.org by "Doğacan Güney (JIRA)" <ji...@apache.org> on 2008/10/01 12:21:44 UTC

[jira] Commented: (NUTCH-648) debian style autocomplete

    [ https://issues.apache.org/jira/browse/NUTCH-648?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12635990#action_12635990 ] 

Doğacan Güney commented on NUTCH-648:
-------------------------------------

This looks great but can you attach your changes as a patch?

> debian style autocomplete
> -------------------------
>
>                 Key: NUTCH-648
>                 URL: https://issues.apache.org/jira/browse/NUTCH-648
>             Project: Nutch
>          Issue Type: Improvement
>         Environment: debian, and other linux
>            Reporter: Jim
>
>         Here is a suggested improvement:  At the end of this file is a debian style bash autocomplete script, just place into /etc/bash_complete.d/ with filename nutch, and you can tab complete at the command prompt, ie
> bash> nutch [tab][tab]
>    crawl readdb convdb mergedb readlinkdb inject generate freegen fetch fetch2 parse
>    readseg mergesegs updatedb invertlinks mergelinkdb index merge dedup plugin server
> bash> nutch c[tab][tab]
>    crawl convdb
> etc.
>    This also includes optional parameters, and filename completion where it can be used.  I really like having this when typing in long nutch commands, and think it would be a great addition to the project.
>    The file is heavily taken from the corresponding svn file that does the same thing.
> File begins here:
> shopt -s extglob
> _nutch()
> {
>        local cur cmds cmdOpts optsParam opt
>        local i
>        COMPREPLY=()
>        cur=${COMP_WORDS[COMP_CWORD]}
>        # Possible expansions
>        cmds='crawl readdb convdb mergedb readlinkdb inject generate freegen fetch fetch2 parse readseg mergesegs updatedb invertlinks \
> mergelinkdb index merge dedup plugin server'
>        if [[ $COMP_CWORD -eq 1 ]] ; then
>                COMPREPLY=( $( compgen -W "$cmds" -- $cur ) )
>                return 0
>        fi
>        # options that require a parameter
>        # This needs to be filled in better
>        optsParam="-topN|-depth"
>        # if not typing an option, or if the previous option required a
>        # parameter, then fallback on ordinary filename expansion
>        if [[ "$cur" != -* ]] || \
>           [[ ${COMP_WORDS[COMP_CWORD-1]} == @($optsParam) ]] ; then
>                return 0
>        fi
>        # possible options for the command
>        cmdOpts=
>        case ${COMP_WORDS[1]} in
>        crawl)
>                cmdOpts="-dir -threads -depth -topN"
>                ;;
>        readdb)
>                cmdOpts="-stats -dump -topN -url"
>                ;;
>        convdb)
>                cmdOpts="-withMetadata"
>                ;;
>        mergedb)
>                cmdOpts="-normalize -filter"
>                ;;
>        readlinkdb)
>                cmdOpts="-dump -url"
>                ;;
>        inject)
>                cmdOpts=""
>                ;;
>        generate)
>                cmdOpts="-force -topN -numFetchers -adddays -noFilter"
>                ;;
>        freegen)
>                cmdOpts="-filter -normalize"
>                ;;
>        fetch)
>                cmdOpts="-threads -noParsing"
>                ;;
>        fetch2)
>                cmdOpts="-threads -noParsing"
>                ;;
>        parse)
>                cmdOpts=""
>                ;;
>        readseg)
>                cmdOpts="-dump -list -get -nocontent -nofetch -nogenerate -noparse -noparsedata -noparsetext -dir"
>                ;;
>        mergesegs)
>                cmdOpts="-dir -filter -slice"
>                ;;
>        updatedb)
>                cmdOpts="-dir -force -normalize -filter -noAdditions"
>                ;;
>        invertlinks)
>                cmdOpts="-dir -force -noNormalize -noFilter"
>                ;;
>        mergelinkdb)
>                cmdOpts="-normalize -filter"
>                ;;
>        index)
>                cmdOpts=""
>                ;;
>        merge)
>                cmdOpts="-workingdir"
>                ;;
>        dedup)
>                cmdOpts=""
>                ;;
>        plugin)
>                cmdOpts=""
>                ;;
>        server)
>                cmdOpts=""
>                ;;
>        *)
>                ;;
>        esac
>        # take out options already given
>        for (( i=2; i<=$COMP_CWORD-1; ++i )) ; do
>                opt=${COMP_WORDS[$i]}
>                cmdOpts=" $cmdOpts "
>                cmdOpts=${cmdOpts/ ${opt} / }
>                # skip next option if this one requires a parameter
>                if [[ $opt == @($optsParam) ]] ; then
>                        ((++i))
>                fi
>        done
>        COMPREPLY=( $( compgen -W "$cmdOpts" -- $cur ) )
>        return 0
> }
> complete -F _nutch -o default nutch

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.