🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.readers
2 messages
2 total messages Started by Christopher Browne Thu, 11 Mar 2004 03:06
Re: command line newsreader?
#144756
Author: Christopher Browne
Date: Thu, 11 Mar 2004 03:06
48 lines
3135 bytes
Oops! notbob <notbob@nothome.com> was seen spray-painting on a wall:
> On 2004-03-11, Christopher Browne <cbbrowne@acm.org> wrote:
>> The "command line" way of news reading would involve using a C-News
>> style spool, and browsing it using NMH.
>
> Bullpucky!
>
> I'm answering this post via ssh from an w98 box thru a Slack box
> running slrn ...no xserver running.  If that ain't command line, I
> don't know what is!

Well, then, you evidently _don't_ know what "command line" is.

slrn is no more a "command line" application than is pan, Knews,
Mozilla, strn, Gnus, or, for that matter, Outlook Express.  They are
all identically "command line" applications in the same trivially
worthless sense that they can all be invoked from a command line.  I
could program buttons on a GNOME panel to invoke any of them (save the
Win32 app, of course!); people would properly consider it nonsense if
I used that fact to justify describing them all as "Gnome
applications."

After being invoked, whether from a command line, or otherwise, they
_all_ do the same thing at that point; they cease to accept "command
line" input, but instead establish some captive user interface.
Whether the captive user interface is SLang (slrn), GTK (pan), Qt
(Knews), GTk (Mozilla), ncurses (strn), Emacs (Gnus), or Win32
(guess?), it is properly nonsense to characterize _any_ of them as
"command line" applications.

Are you at the command line typing in commands like:

$ folder +comp.os.linux.misc
$ scan
$ show 82-90
$ reply 82
???

That's the way a "command line" style of news reading would work, and
is, in fact, the model established by Rand when they first deployed
MH.  The O.P. asked for "command line;" that involves the model of
controlling things via a _command line_.
-- 
output = reverse("gro.mca" "@" "enworbbc")
http://cbbrowne.com/info/mail.html#MH
Random hacker: Oz needs to be booted.
RMS: Ok, I'll break open a window.
Re: command line newsreader?
#144766
Author: Chris F.A. Johnson
Date: Thu, 11 Mar 2004 08:25
153 lines
4807 bytes
On Thu, 11 Mar 2004 at 03:06 GMT, Christopher Browne wrote:
> 
> Are you at the command line typing in commands like:
> 
> $ folder +comp.os.linux.misc
> $ scan
> $ show 82-90
> $ reply 82
> ???
> 
> That's the way a "command line" style of news reading would work, and
> is, in fact, the model established by Rand when they first deployed
> MH.  The O.P. asked for "command line;" that involves the model of
> controlling things via a _command line_.

    Something like this?

    (Type "help" for the commands implemented so far.)

#!/bin/bash
# Thu Mar 11 02:13:02 EST 2004
# NAME: cjnews
# DESCRIPTION: [the beginnings of] a command-line news reader
# Copyright 2004, Chris F.A. Johnson
# Released under the terms of the GNU General Public License

## fill in necessary information here
host=$NNTPSERVER
port=119
user=
pass=

## or put it in $HOME/.cnewsrc, which will  be sourced
[ -f "$HOME/.cnewsrc" ] && . $HOME/.cnewsrc

help() {
    echo "

    COMMANDS:
       folder [+]GROUP  - select GROUP
       group  [+]GROUP  - select GROUP
       head   NUMBER    - retrieve the head of message no. NUMBER
       body   NUMBER    - retrieve message no. NUMBER
       stat   NUMBER    - get statistics for message no. NUMBER
       help             - show this screen
       quit             - exit cjnews
"
}

tcpread() {
    while IFS= read -r line <&3
    do
      line=${line%$CR}
      case $line in
          .) break ;;
          *) printf "%s\n" "$line" ;;
      esac
    done
}

tcpcmd() {
    local IFS=${IFS}$'\r'
    cmd=$*
    echo $cmd >&3
    read ok msg <&3
    printf "%s\n" "$ok $msg"
    [ ${ok:-666} -lt 400 ]
}

quit() {
    tcpcmd quit
    echo Exit code: $1
    exit $(( $1 % 255 ))
}

folder() {
    [ -z "$1" ] && { printf "%s\n" "USAGE: $FUNCNAME [+]name.of.group"; return 192; }
    tcpcmd group "${1#+}" && prompt=${1#+}
}

group() {
    [ -z "$1" ] && { printf "%s\n" "USAGE: $FUNCNAME [+]name.of.group"; return 192; }
    tcpcmd group "${1#+}" && prompt=${1#+}
}

stat() {
    [ -z "$1" ] && { printf "%s\n" "USAGE: $FUNCNAME NUMBER"; return 192; }
    tcpcmd stat "${@}"
}

head() {
    [ -z "$1" ] && { printf "%s\n" "USAGE: $FUNCNAME NUMBER"; return 192; }
    tcpcmd head "${@}" && echo || return 192
    tcpread
}

body() {
    [ -z "$1" ] && { printf "%s\n" "USAGE: $FUNCNAME NUMBER"; return 192; }
    tcpcmd body "${@}" && echo || return 192
    tcpread
}

HISTFILE=$HOME/.cnewshist

[ -f "$HISTFILE" ] || touch $HISTFILE
history -r
CR=$'\r'
NL=$'\n'

exec 3<>/dev/tcp/$host/$port
read ok msg <&3
echo "$ok $line"
case $ok in
    200|201) echo "Connected to $host" ;;
    *) quit 192 ;;
esac

[ -n "$user" ] && tcpcmd authinfo simple $user $pass || quit $ok

while :
do
    read -ep "${prompt:-$host}:: " cmd

    ## there must be an easier way to use history in a script
    history -w
    history -s "$cmd"
    history -a
    history -c
    history -r

    case $cmd in
        q|Q|[Bb][Yy][Ee]|[Qq][Uu][Ii][Tt]) break ;;
        [Gg][Rr][Oo][Uu][Pp]* ) ${cmd} ;;
        [Ff][Oo][Ll][Dd][Ee][Rr]*) $cmd ;;
        [Ss][Tt][Aa][Tt]*) $cmd ;;
        [Hh][Ee][Aa][Dd]*) $cmd ;;
        [Bb][Oo][Dd][Yy]*) $cmd ;;
        *) help ;;
    esac
done

tempfile=$HOME/.cnews-histfile-$$
uniq "$HISTFILE" > $tempfile
mv -b $tempfile "$HISTFILE"

quit 0

-- 
    Chris F.A. Johnson                  http://cfaj.freeshell.org/shell
    ===================================================================
    My code (if any) in this post is copyright 2004, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads