mirror of
https://codeberg.org/scip/note.git
synced 2025-12-17 04:31:02 +01:00
ADDED: "-" works also for --dump, but in the other direction. It causes
note to dump to standard output instead into a file.
ADDED: you can specify - as filename for use with --import and if you want
to create a new note. "-" stands for standardinput and it allows you
tp pipe another commands output to note!
ADDED: you can now use an environment variable for the passphrase (when using
encryption). If it is presen, note will not ask for a passphrase. This
is very usefull in comination with the addition above, for use in
scripts.
CHANGED: the interactive help screen is now coloured.
ADDED: -o commandline switch, which causes note to overwrite an existing
database when importing data from a previous dump. Very handy if
you want to re-initialize your db, i.e. if you changed the format.
ADDED: the long-tree-view (-T) displays now also the note-number of each
note.
This commit is contained in:
19
Changelog
19
Changelog
@@ -1,5 +1,24 @@
|
|||||||
==================================================================================
|
==================================================================================
|
||||||
|
|
||||||
|
1.0.3:
|
||||||
|
ADDED: "-" works also for --dump, but in the other direction. It causes
|
||||||
|
note to dump to standard output instead into a file.
|
||||||
|
ADDED: you can specify - as filename for use with --import and if you want
|
||||||
|
to create a new note. "-" stands for standardinput and it allows you
|
||||||
|
tp pipe another commands output to note!
|
||||||
|
ADDED: you can now use an environment variable for the passphrase (when using
|
||||||
|
encryption). If it is presen, note will not ask for a passphrase. This
|
||||||
|
is very usefull in comination with the addition above, for use in
|
||||||
|
scripts.
|
||||||
|
CHANGED: the interactive help screen is now coloured.
|
||||||
|
ADDED: -o commandline switch, which causes note to overwrite an existing
|
||||||
|
database when importing data from a previous dump. Very handy if
|
||||||
|
you want to re-initialize your db, i.e. if you changed the format.
|
||||||
|
ADDED: the long-tree-view (-T) displays now also the note-number of each
|
||||||
|
note.
|
||||||
|
|
||||||
|
==================================================================================
|
||||||
|
|
||||||
1.0.2:
|
1.0.2:
|
||||||
ADDED: Topic-Tree overview command (-t or -T).
|
ADDED: Topic-Tree overview command (-t or -T).
|
||||||
ADDED: Enhanced list command in interactive mode, you can now specify
|
ADDED: Enhanced list command in interactive mode, you can now specify
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ sub chk_mod
|
|||||||
print "<====\tchecking $mod \t====>\n";
|
print "<====\tchecking $mod \t====>\n";
|
||||||
eval {
|
eval {
|
||||||
$mod .= ".pm";
|
$mod .= ".pm";
|
||||||
|
$mod =~ s/::/\//g;
|
||||||
require $mod;
|
require $mod;
|
||||||
};
|
};
|
||||||
if($@) {
|
if($@) {
|
||||||
|
|||||||
@@ -86,6 +86,14 @@ sub use_crypt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub set_del_all
|
||||||
|
{
|
||||||
|
unlink $NOTEDB;
|
||||||
|
open(TT,">$NOTEDB") or die "Could not create $NOTEDB: $!\n";
|
||||||
|
close (TT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sub get_single
|
sub get_single
|
||||||
{
|
{
|
||||||
my($this, $num) = @_;
|
my($this, $num) = @_;
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ my $sql_edit = "UPDATE $table SET $fnote = ?, $fdate = ? WHERE $fnum = ?";
|
|||||||
my $sql_insertnew = "INSERT INTO $table VALUES (?, ?, ?)";
|
my $sql_insertnew = "INSERT INTO $table VALUES (?, ?, ?)";
|
||||||
|
|
||||||
my $sql_del = "DELETE FROM $table WHERE $fnum = ?";
|
my $sql_del = "DELETE FROM $table WHERE $fnum = ?";
|
||||||
|
my $sql_del_all = "DELETE FROM $table";
|
||||||
######################################################################################################
|
######################################################################################################
|
||||||
|
|
||||||
sub new
|
sub new
|
||||||
@@ -213,6 +214,14 @@ sub set_del
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub set_del_all
|
||||||
|
{
|
||||||
|
my($this) = @_;
|
||||||
|
my $statement = $DB->prepare($sql_del_all) || die $DB->errstr();
|
||||||
|
$statement->execute() || die $DB->errstr();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
sub set_recountnums
|
sub set_recountnums
|
||||||
{
|
{
|
||||||
my $this = shift;
|
my $this = shift;
|
||||||
|
|||||||
62
README
62
README
@@ -1,4 +1,4 @@
|
|||||||
note 1.0.2 by Thomas Linden, 01/05/2000
|
note 1.0.3 by Thomas Linden, 02/05/2000
|
||||||
|
|
||||||
|
|
||||||
Introduction
|
Introduction
|
||||||
@@ -87,7 +87,8 @@ Usage
|
|||||||
|
|
||||||
To create a new note, simply run "note". You can enter
|
To create a new note, simply run "note". You can enter
|
||||||
the note (the length is by default limited to 4096 bytes,
|
the note (the length is by default limited to 4096 bytes,
|
||||||
which you can change from your config file).
|
which you can change from your config file if you are using
|
||||||
|
the binary backend, therwise there is no limitation).
|
||||||
End by typing a . on a line itself. note will tell you the
|
End by typing a . on a line itself. note will tell you the
|
||||||
number of the note.
|
number of the note.
|
||||||
|
|
||||||
@@ -108,7 +109,7 @@ Usage
|
|||||||
strcture. You can use the command "-t" in this case, which
|
strcture. You can use the command "-t" in this case, which
|
||||||
will display a tree-view of your tpic-structure. You can
|
will display a tree-view of your tpic-structure. You can
|
||||||
use the command "-T" if you want to see the notes under each
|
use the command "-T" if you want to see the notes under each
|
||||||
topic too.
|
topic too. "-T" will also show the number of each note.
|
||||||
|
|
||||||
To edit a certain note, type "note -e 1". It will invoke your
|
To edit a certain note, type "note -e 1". It will invoke your
|
||||||
editor (vi or pico). You can edit it, after saving, note
|
editor (vi or pico). You can edit it, after saving, note
|
||||||
@@ -142,6 +143,22 @@ Usage
|
|||||||
your note-dump form your office to home and import it there
|
your note-dump form your office to home and import it there
|
||||||
for further use).
|
for further use).
|
||||||
The dumps from the two versions of note are in the same format.
|
The dumps from the two versions of note are in the same format.
|
||||||
|
Using dumps it is also possible to reinitialize your database. You
|
||||||
|
can use the "-o" switch whcih causes note to overwrite your existing
|
||||||
|
database. This is very handy if you changed heavily your config. And
|
||||||
|
it is required, if you changed: encryption, db-driver, (binary-format)
|
||||||
|
and the password. You can use the following command for reinitializing:
|
||||||
|
$ note -D - | note -o -I -
|
||||||
|
What the hell, does it?! Step by step:
|
||||||
|
o "note -D -" creates a note-database dump and prints it out
|
||||||
|
to stantdard output.
|
||||||
|
o "|" this is the shell's pipe command. It does take the output
|
||||||
|
of the left program and gives it to the right progrem as standard
|
||||||
|
input.
|
||||||
|
o "note -o -I -" imports a note-database dump from standard input
|
||||||
|
and overwrites an existing database.
|
||||||
|
Before you use the "-o" switch, I consider yuo to make a backup!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -216,6 +233,32 @@ Topics
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Scripting
|
||||||
|
=========
|
||||||
|
|
||||||
|
Since version 1.0.3 there are some additions which allows you to use note in
|
||||||
|
scripts, without user-interaction. You might run a special script as cronjob,
|
||||||
|
which adds a note under a certain topic every week. Or the like.
|
||||||
|
|
||||||
|
Here are the possibilies you have:
|
||||||
|
|
||||||
|
You can add a new note through a pipe, another commands output becomes
|
||||||
|
note's input:
|
||||||
|
$ cat /var/spool/news/daily | note -
|
||||||
|
This command adds the content of a file "daily" as a new note. Note the dash.
|
||||||
|
it stands for "Standard Input". Note will be completely silent and it will not
|
||||||
|
ask for something.
|
||||||
|
|
||||||
|
Suppose you are using encryption. You might wonder, how note will get your
|
||||||
|
passphrase? The solution: You need to set up an environment variable which
|
||||||
|
contains the password:
|
||||||
|
$ export NOTE_PASSWD=secret
|
||||||
|
If the variable is present, note will not ask you for a passphrase!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Format of the notedb (binary backend)
|
Format of the notedb (binary backend)
|
||||||
=====================================
|
=====================================
|
||||||
|
|
||||||
@@ -311,6 +354,8 @@ Security
|
|||||||
the file UPGRADE and follow it's directions!
|
the file UPGRADE and follow it's directions!
|
||||||
Someday I will add a "change passwd" function, which will do all
|
Someday I will add a "change passwd" function, which will do all
|
||||||
these things for you. Someday, I said...
|
these things for you. Someday, I said...
|
||||||
|
For now you can use the "re-initialze database" functionality, mentioned
|
||||||
|
earlier in the "Usage" section (at the end of the section).
|
||||||
|
|
||||||
Note: To make sure, the encrypted data can be stored properly,
|
Note: To make sure, the encrypted data can be stored properly,
|
||||||
it will be uuencoded after encryption.
|
it will be uuencoded after encryption.
|
||||||
@@ -321,6 +366,15 @@ Security
|
|||||||
the phrase, then the data can't be decrypted. Even if it
|
the phrase, then the data can't be decrypted. Even if it
|
||||||
is possible - I am not responsible for that!
|
is possible - I am not responsible for that!
|
||||||
|
|
||||||
|
Note: How does note know, if the passphrase was incorrect? It uses the
|
||||||
|
specified phrase and encodes at least one note (the first one)
|
||||||
|
and checks if the decrypted timestamp field matches the following
|
||||||
|
expression: "^\d+\.\d+". Translated from perl to human:
|
||||||
|
the timestamp must begin with minimum one digit (possibly more),
|
||||||
|
followed by one dot, followed by minimum one digit (possibly more).
|
||||||
|
Chances are bad, that a wrong passphrase will cause a timestamp
|
||||||
|
matching the rule above. If you have other experiences, please
|
||||||
|
drop me a mail!
|
||||||
|
|
||||||
|
|
||||||
Comments
|
Comments
|
||||||
@@ -353,4 +407,4 @@ Author and Copyright
|
|||||||
Last changed
|
Last changed
|
||||||
============
|
============
|
||||||
|
|
||||||
18/04/2000
|
02/05/2000
|
||||||
|
|||||||
2
UPGRADE
2
UPGRADE
@@ -1,4 +1,4 @@
|
|||||||
READ THIS FILE, IF YOU ARE UPGRADING FROM 0.9 TO 1.0.0
|
READ THIS FILE, IF YOU ARE UPGRADING FROM 0.9 TO 1.0.x
|
||||||
======================================================
|
======================================================
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
235
bin/note
235
bin/note
@@ -1,7 +1,16 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
# $Author: thomas $ $Id: note,v 1.19 2000/04/30 16:07:23 thomas Exp thomas $ $Revision: 1.19 $
|
# $Author: thomas $ $Id: note,v 1.22 2000/05/01 18:51:40 thomas Exp thomas $ $Revision: 1.22 $
|
||||||
#
|
#
|
||||||
# $Log: note,v $
|
# $Log: note,v $
|
||||||
|
# Revision 1.22 2000/05/01 18:51:40 thomas
|
||||||
|
# added "-" to sub dump
|
||||||
|
#
|
||||||
|
# Revision 1.21 2000/05/01 00:17:27 thomas
|
||||||
|
# *** empty log message ***
|
||||||
|
#
|
||||||
|
# Revision 1.20 2000/04/30 23:31:38 thomas
|
||||||
|
# added -o and coloured sub help.
|
||||||
|
#
|
||||||
# Revision 1.19 2000/04/30 16:07:23 thomas
|
# Revision 1.19 2000/04/30 16:07:23 thomas
|
||||||
# *** empty log message ***
|
# *** empty log message ***
|
||||||
#
|
#
|
||||||
@@ -97,9 +106,10 @@ sub help;
|
|||||||
sub import;
|
sub import;
|
||||||
sub display_tree;
|
sub display_tree;
|
||||||
sub tree;
|
sub tree;
|
||||||
|
sub print_tree;
|
||||||
|
|
||||||
my (
|
my (
|
||||||
$maxlen, $timelen, $TOPIC, $TYPE, $mode, $NOTEDB, $NoteKey,
|
$maxlen, $timelen, $TOPIC, $TYPE, $mode, $NOTEDB, $NoteKey, $ImportType, $NewType,
|
||||||
$version, $number, $CurTopic, $CurDepth, $PATH, $CONF, $WantTopic,
|
$version, $number, $CurTopic, $CurDepth, $PATH, $CONF, $WantTopic,
|
||||||
$sizeof, $MAX_TIME, $PreferredEditor, %TP, $TopicSep,
|
$sizeof, $MAX_TIME, $PreferredEditor, %TP, $TopicSep,
|
||||||
$TreeType, $ListType, $searchstring, $dump_file, $ALWAYS_INT, $KEEP_TIMESTAMP,
|
$TreeType, $ListType, $searchstring, $dump_file, $ALWAYS_INT, $KEEP_TIMESTAMP,
|
||||||
@@ -136,7 +146,7 @@ $TIME_COLOR = "black";
|
|||||||
$TOPIC_COLOR = "BLACK";
|
$TOPIC_COLOR = "BLACK";
|
||||||
$TOPIC = 1;
|
$TOPIC = 1;
|
||||||
$TopicSep = '/';
|
$TopicSep = '/';
|
||||||
$version = "1.0.2";
|
$version = "1.0.3";
|
||||||
if($TOPIC)
|
if($TOPIC)
|
||||||
{
|
{
|
||||||
$CurDepth = 1; # the current depth inside the topic "directory" structure...
|
$CurDepth = 1; # the current depth inside the topic "directory" structure...
|
||||||
@@ -165,6 +175,12 @@ else
|
|||||||
}
|
}
|
||||||
$ARGV[0] = "";
|
$ARGV[0] = "";
|
||||||
}
|
}
|
||||||
|
elsif($ARGV[0] eq "-")
|
||||||
|
{
|
||||||
|
$NewType = 1;
|
||||||
|
$mode = "new";
|
||||||
|
$ARGV[0] = "";
|
||||||
|
}
|
||||||
elsif($ARGV[0] eq "-i" || $ARGV[0] eq "--interactive")
|
elsif($ARGV[0] eq "-i" || $ARGV[0] eq "--interactive")
|
||||||
{
|
{
|
||||||
$mode = "interactive";
|
$mode = "interactive";
|
||||||
@@ -241,10 +257,35 @@ else
|
|||||||
print "no dumpfile specified, using $dump_file.\n";
|
print "no dumpfile specified, using $dump_file.\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
elsif($ARGV[0] eq "-o" || $ARGV[0] eq "--overwrite")
|
||||||
|
{
|
||||||
|
$mode = "import";
|
||||||
|
$ImportType = $ARGV[0];
|
||||||
|
if($ARGV[1] eq "-I" || $ARGV[1] eq "--Import") {
|
||||||
|
$dump_file = $ARGV[2];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print "--overwrite is only suitable for use with --import!\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
$ARGV[0] = "";
|
||||||
|
if($dump_file eq "")
|
||||||
|
{
|
||||||
|
print "No dumpfile specified.\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
elsif($ARGV[0] eq "-I" || $ARGV[0] eq "--Import" || $ARGV[0] eq "--import")
|
elsif($ARGV[0] eq "-I" || $ARGV[0] eq "--Import" || $ARGV[0] eq "--import")
|
||||||
{
|
{
|
||||||
$mode = "import";
|
$mode = "import";
|
||||||
|
if($ARGV[1] eq "-o" || $ARGV[1] eq "-overwrite") {
|
||||||
|
$dump_file = $ARGV[2];
|
||||||
|
$ImportType = $ARGV[1];
|
||||||
|
}
|
||||||
|
else {
|
||||||
$dump_file = $ARGV[1];
|
$dump_file = $ARGV[1];
|
||||||
|
$ImportType = $ARGV[2];
|
||||||
|
}
|
||||||
$ARGV[0] = "";
|
$ARGV[0] = "";
|
||||||
if($dump_file eq "")
|
if($dump_file eq "")
|
||||||
{
|
{
|
||||||
@@ -340,6 +381,7 @@ if($USE_CRYPT eq "YES" && $NOTEDB::crypt_supported == 1) {
|
|||||||
if($CRYPT_METHOD eq "") {
|
if($CRYPT_METHOD eq "") {
|
||||||
$CRYPT_METHOD = "Crypt::IDEA";
|
$CRYPT_METHOD = "Crypt::IDEA";
|
||||||
}
|
}
|
||||||
|
if(!exists $ENV{'NOTE_PASSWD'}) {
|
||||||
print "password: ";
|
print "password: ";
|
||||||
eval {
|
eval {
|
||||||
local($|) = 1;
|
local($|) = 1;
|
||||||
@@ -354,6 +396,10 @@ if($USE_CRYPT eq "YES" && $NOTEDB::crypt_supported == 1) {
|
|||||||
if($@) {
|
if($@) {
|
||||||
$key = <>;
|
$key = <>;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$key = $ENV{'NOTE_PASSWD'};
|
||||||
|
}
|
||||||
chomp $key;
|
chomp $key;
|
||||||
$db->use_crypt($key,$CRYPT_METHOD);
|
$db->use_crypt($key,$CRYPT_METHOD);
|
||||||
undef $key;
|
undef $key;
|
||||||
@@ -625,6 +671,13 @@ sub new
|
|||||||
$note = "";
|
$note = "";
|
||||||
$line = "";
|
$line = "";
|
||||||
# create a new note
|
# create a new note
|
||||||
|
if($NewType)
|
||||||
|
{
|
||||||
|
# be silent! read from STDIN until EOF.
|
||||||
|
while (<STDIN>) { $note .= $_; }
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
print "enter the text of the note, end with .\n";
|
print "enter the text of the note, end with .\n";
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@@ -635,6 +688,7 @@ sub new
|
|||||||
chop $note;
|
chop $note;
|
||||||
chop $note;
|
chop $note;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# since we have not number, look for the next available:
|
# since we have not number, look for the next available:
|
||||||
$number = $db->get_nextnum();
|
$number = $db->get_nextnum();
|
||||||
@@ -738,14 +792,20 @@ sub edit
|
|||||||
|
|
||||||
sub dump
|
sub dump
|
||||||
{
|
{
|
||||||
my(%res, $num);
|
my(%res, $num, $DUMP);
|
||||||
# $dump_file
|
# $dump_file
|
||||||
open (DUMP, ">$dump_file") or die "could not open $dump_file\n";
|
if($dump_file eq "-") {
|
||||||
select DUMP;
|
$DUMP = *STDOUT;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
open (DUMPFILE, ">$dump_file") or die "could not open $dump_file\n";
|
||||||
|
$DUMP = *DUMPFILE;
|
||||||
|
}
|
||||||
|
select $DUMP;
|
||||||
%res = $db->get_all();
|
%res = $db->get_all();
|
||||||
foreach $num (sort { $a <=> $b } keys %res)
|
foreach $num (sort { $a <=> $b } keys %res)
|
||||||
{
|
{
|
||||||
print STDOUT "dumping note number $num to $dump_file\n";
|
print STDOUT "dumping note number $num to $dump_file\n" if($dump_file ne "-");
|
||||||
print "Number: $num\n"
|
print "Number: $num\n"
|
||||||
."Timestamp: $res{$num}->{'date'}\n"
|
."Timestamp: $res{$num}->{'date'}\n"
|
||||||
."$res{$num}->{'note'}\n";
|
."$res{$num}->{'note'}\n";
|
||||||
@@ -757,12 +817,20 @@ sub dump
|
|||||||
|
|
||||||
sub import
|
sub import
|
||||||
{
|
{
|
||||||
my($num, $start, $complete, $dummi, $note, $date, $time, $number);
|
my($num, $start, $complete, $dummi, $note, $date, $time, $number, $stdin, $DUMP);
|
||||||
# open $dump_file and import it into the notedb
|
# open $dump_file and import it into the notedb
|
||||||
open (DUMP, "<$dump_file") or die "could not open $dump_file\n";
|
$stdin = 1 if($dump_file eq "-");
|
||||||
|
if($stdin) {
|
||||||
|
$DUMP = *STDIN;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
open (DUMPFILE, "<$dump_file") or die "could not open $dump_file\n";
|
||||||
|
$DUMP = *DUMPFILE;
|
||||||
|
}
|
||||||
|
$db->set_del_all() if($ImportType ne "");
|
||||||
$complete=0;
|
$complete=0;
|
||||||
$start = 0;
|
$start = 0;
|
||||||
while(<DUMP>)
|
while(<$DUMP>)
|
||||||
{
|
{
|
||||||
chomp $_;
|
chomp $_;
|
||||||
if($_ =~ /^Number:\s\d+/)
|
if($_ =~ /^Number:\s\d+/)
|
||||||
@@ -778,7 +846,7 @@ sub import
|
|||||||
# we got a complete record, save it!
|
# we got a complete record, save it!
|
||||||
$number = $db->get_nextnum();
|
$number = $db->get_nextnum();
|
||||||
$db->set_new($number,$note, $date);
|
$db->set_new($number,$note, $date);
|
||||||
print "note number $number from $dump_file inserted into notedb.\n";
|
print "note number $number from $dump_file inserted into notedb.\n" if(!$stdin);
|
||||||
$complete = 0;
|
$complete = 0;
|
||||||
$note = "";
|
$note = "";
|
||||||
$date = "";
|
$date = "";
|
||||||
@@ -801,7 +869,7 @@ sub import
|
|||||||
# the last record, if existent
|
# the last record, if existent
|
||||||
$number = $db->get_nextnum();
|
$number = $db->get_nextnum();
|
||||||
$db->set_new($number,$note, $date);
|
$db->set_new($number,$note, $date);
|
||||||
print "note number $number from $dump_file inserted into notedb.\n";
|
print "note number $number from $dump_file inserted into notedb.\n" if(!$stdin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -809,27 +877,21 @@ sub import
|
|||||||
|
|
||||||
sub interactive
|
sub interactive
|
||||||
{
|
{
|
||||||
#$|=1;
|
|
||||||
#my $term = new Term::ReadLine('');
|
|
||||||
#my $OUT = $term->OUT || *STDOUT;
|
|
||||||
#my $term->MinLine(undef);
|
|
||||||
#my $attribs = $term->Attribs;
|
|
||||||
#$term->bind_key(ord "\cc", 'abort');
|
|
||||||
my($maxlen_save, $B, $BB, $menu, $char, @LastTopic);
|
my($maxlen_save, $B, $BB, $menu, $char, @LastTopic);
|
||||||
$maxlen_save = $maxlen;
|
$maxlen_save = $maxlen;
|
||||||
# create menu:
|
# create menu:
|
||||||
$B = "<blackI>";
|
$B = "<blackI>";
|
||||||
$BB = "</blackI>";
|
$BB = "</blackI>";
|
||||||
$menu = "[" . $B . "L" . $BB . " List ";
|
$menu = "[" . $B . "L" . $BB . "-List ";
|
||||||
if($TOPIC) {
|
if($TOPIC) {
|
||||||
$menu .= $B . "T" . $BB . " Topics ";
|
$menu .= $B . "T" . $BB . "-Topics ";
|
||||||
}
|
}
|
||||||
$menu .= $B . "N" . $BB . " New "
|
$menu .= $B . "N" . $BB . "-New "
|
||||||
. $B . "D" . $BB . " Delete "
|
. $B . "D" . $BB . "-Delete "
|
||||||
. $B . "S" . $BB . " Search "
|
. $B . "S" . $BB . "-Search "
|
||||||
. $B . "E" . $BB . " Edit "
|
. $B . "E" . $BB . "-Edit "
|
||||||
. $B . "?" . $BB . " Help "
|
. $B . "?" . $BB . "-Help "
|
||||||
. $B . "Q" . $BB . " Quit] "; # $CurTopic will be empty if $TOPIC is off!
|
. $B . "Q" . $BB . "-Quit] "; # $CurTopic will be empty if $TOPIC is off!
|
||||||
# per default let's list all the stuff:
|
# per default let's list all the stuff:
|
||||||
# Initially do a list command!
|
# Initially do a list command!
|
||||||
$maxlen += $timelen;
|
$maxlen += $timelen;
|
||||||
@@ -1015,23 +1077,30 @@ sub usage
|
|||||||
print qq~This is the program note $version by Thomas Linden (c) 1999-2000.
|
print qq~This is the program note $version by Thomas Linden (c) 1999-2000.
|
||||||
It comes with absolutely NO WARRANTY. It is distributed under the
|
It comes with absolutely NO WARRANTY. It is distributed under the
|
||||||
terms of the GNU General Public License. Use it at your own risk :-)
|
terms of the GNU General Public License. Use it at your own risk :-)
|
||||||
Usage: note [-i | --interactive] | [ options ] [ number [,number...]]
|
Usage: note [ options ] [ number [,number...]]
|
||||||
Options:
|
Options:
|
||||||
-h --help displays this help screen
|
-h --help displays this help screen
|
||||||
-v --version displays the version number
|
-v --version displays the version number
|
||||||
-l --list [<topic>] lists all existing notes If no topic were specified,
|
-l --list [<topic>] lists all existing notes If no topic were specified,
|
||||||
it will display a list of all existing topics.
|
it will display a list of all existing topics.
|
||||||
-L --longlist [<topic>] the same as -l but prints also the timestamp
|
-L --longlist [<topic>] the same as -l but prints also the timestamp
|
||||||
-t --topic prints a list of all topics as a tree.
|
-t --topic prints a list of all topics as a tree.
|
||||||
-T --longtopc prints the topic-tree with the notes under each topic
|
-T --longtopc prints the topic-tree with the notes under each topic
|
||||||
-s --search <string> searches for <string> trough the notes database
|
-s --search <string> searches for <string> trough the notes database
|
||||||
-e --edit <number> edit note with <number>
|
-e --edit <number> edit note with <number>
|
||||||
-d --delete <number> delete note with <number>
|
-d --delete <number> delete note with <number>
|
||||||
-D --Dump [<file>] dumps the notes to the textfile <file>
|
-D --Dump [<file> | -] dumps the notes to the textfile <file>. if <file> is simply
|
||||||
-I --Import <file> imports a previously dumped textfile into the
|
a "-" it will printed out to standard output.
|
||||||
note-database. Dumps from the mysql and the binary
|
-I --Import <file> | - imports a previously dumped textfile into the
|
||||||
version are in the same format.
|
note-database. Data will be appended by default.
|
||||||
-i --interactive interactive mode
|
You can also specify a dash "note -I -" instead of a <file>,
|
||||||
|
which causes note, silently to read in a dump from STDIN.
|
||||||
|
-o --overwrite only suitable for use with --Import. Overwrites an
|
||||||
|
existing notedb.
|
||||||
|
-i --interactive interactive mode
|
||||||
|
- if you run note only with one dash: "note -", then it will
|
||||||
|
read in a new note from STDIN until EOF, this makes it
|
||||||
|
possible to pipe text into a new note.
|
||||||
|
|
||||||
o if you specify only a number (i.e. "note 4"), then the note with that
|
o if you specify only a number (i.e. "note 4"), then the note with that
|
||||||
number will be displayed.
|
number will be displayed.
|
||||||
@@ -1043,6 +1112,9 @@ Options:
|
|||||||
informations about the configuration.
|
informations about the configuration.
|
||||||
o In interactive mode you can get help at any time by typing "?" or "h" at
|
o In interactive mode you can get help at any time by typing "?" or "h" at
|
||||||
the prompt.
|
the prompt.
|
||||||
|
o If encryption support is turned on, note will ask you for a passphrase every
|
||||||
|
time it runs. You can avoid this behavior by setting the environment-variable
|
||||||
|
\$NOTE_PASSWD. You will need this for example, if you call note from a script.
|
||||||
~;
|
~;
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
@@ -1296,44 +1368,54 @@ sub getdate
|
|||||||
|
|
||||||
sub help
|
sub help
|
||||||
{
|
{
|
||||||
print qq~
|
my $B = "<blackI>";
|
||||||
--------------------------------------------------------------
|
my $BB = "</blackI>";
|
||||||
HELP for interactive note $version
|
my($S, $L, $T, $Q, $H, $N, $D, $E);
|
||||||
|
$L = $B . "L" . $BB . $NOTEC;
|
||||||
|
$T = $B . "T" . $BB . $NOTEC;
|
||||||
|
$Q = $B . "Q" . $BB . $NOTEC;
|
||||||
|
$H = $B . "?" . $BB . $NOTEC;
|
||||||
|
$N = $B . "N" . $BB . $NOTEC;
|
||||||
|
$D = $B . "D" . $BB . $NOTEC;
|
||||||
|
$E = $B . "E" . $BB . $NOTEC;
|
||||||
|
$S = $B . "S" . $BB . $NOTEC;
|
||||||
|
|
||||||
|
print C qq~$BORDERC
|
||||||
|
----------------------------------------------------------------------$_BORDERC $TOPICC
|
||||||
|
HELP for interactive note $version
|
||||||
|
$_TOPICC $NOTEC
|
||||||
The following commands are available:
|
The following commands are available:
|
||||||
L/l List notes. L=long, with timestamp and l=short without timestamp.
|
$L List notes. L=long, with timestamp and l=short without timestamp.
|
||||||
You can also just hit <enter> for short list.
|
You can also just hit <enter> for short list.
|
||||||
If you specify a subtopic, then list will display it's contents, i.e.
|
If you specify a subtopic, then list will display it's contents,
|
||||||
"l mytopic" will dislpay notes under mytopic.
|
i.e.: "l mytopic" will dislpay notes under mytopic.
|
||||||
N Create a new note.
|
$N Create a new note.
|
||||||
D Delete a note. You can either hit "d 1" or "d 1-4" or just hit "d".
|
$D Delete a note. You can either hit "d 1" or "d 1-4" or just hit "d".
|
||||||
If you don't specify a number, you will be asked for.
|
If you don't specify a number, you will be asked for.
|
||||||
S Search trough the notes database. Usage is similar to Delete, use
|
$S Search trough the notes database. Usage is similar to Delete, use
|
||||||
a string instead of a number to search for.
|
a string instead of a number to search for.
|
||||||
E Edit a note. Usage is similar to Delete but you can only edit note
|
$E Edit a note. Usage is similar to Delete but you can only edit note
|
||||||
a time.~;
|
a time.
|
||||||
|
$H This help screen.
|
||||||
|
$Q Exit the program.~;
|
||||||
if($TOPIC)
|
if($TOPIC)
|
||||||
{
|
{
|
||||||
print qq~
|
print C qq~
|
||||||
T/t print a list of all existing topics as a tree. T prints the tree with
|
$T print a list of all existing topics as a tree. T prints the tree
|
||||||
all notes under each topic.
|
with all notes under each topic.
|
||||||
=====>
|
|
||||||
You can change the actual topic by simply typing it's name or by
|
|
||||||
using the command "cd", i.e. "cd mytopic".
|
|
||||||
You can create a new topic by creating a new note, the first line
|
|
||||||
must be the topic borderd by slashes, i.e. "/newtopic/". The slash
|
|
||||||
is the default topic-sepearator, but you can override thie in the
|
|
||||||
config!
|
|
||||||
If you type just ".." instead of a topic, you will go one step back
|
|
||||||
in your topic-structure.
|
|
||||||
=====>~;
|
|
||||||
}
|
|
||||||
print qq~
|
|
||||||
?/H This help screen.
|
|
||||||
Q Exit the program.
|
|
||||||
|
|
||||||
All commands except the List command are case insensitive.
|
You can change the actual topic by simply typing it's name or by using
|
||||||
---------------------------------------------------------------
|
the command "cd", i.e. "cd mytopic". You can create a new topic by creating
|
||||||
|
a new note, the first line must be the topic borderd by slashes, i.e.:
|
||||||
|
"/newtopic/". The slash is the default topic-sepearator, but you can over-
|
||||||
|
ride this in the config! If you type just ".." instead of a topic, you will
|
||||||
|
go one step back in your topic-structure.
|
||||||
|
~;
|
||||||
|
}
|
||||||
|
print C qq~
|
||||||
|
$NOTEC
|
||||||
|
All commands except the List command are case insensitive. $_NOTEC $BORDERC
|
||||||
|
----------------------------------------------------------------------$_BORDERC
|
||||||
~;
|
~;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1358,7 +1440,7 @@ sub display_tree {
|
|||||||
@nodes = ();("$TopicSep");
|
@nodes = ();("$TopicSep");
|
||||||
$text = $firstline;
|
$text = $firstline;
|
||||||
}
|
}
|
||||||
&tree($text, \%TREE, @nodes);
|
&tree($num, $text, \%TREE, @nodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
# now that we have build our tree (in %TREE) go on t display it:
|
# now that we have build our tree (in %TREE) go on t display it:
|
||||||
@@ -1369,14 +1451,18 @@ sub display_tree {
|
|||||||
|
|
||||||
|
|
||||||
sub tree {
|
sub tree {
|
||||||
my($text, $LocalTree, $node, @nodes) = @_;
|
my($num, $text, $LocalTree, $node, @nodes) = @_;
|
||||||
if(@nodes) {
|
if(@nodes) {
|
||||||
if(! exists $LocalTree->{$node}->{$NoteKey}) {
|
if(! exists $LocalTree->{$node}->{$NoteKey}) {
|
||||||
$LocalTree->{$node}->{$NoteKey} = [];
|
$LocalTree->{$node}->{$NoteKey} = [];
|
||||||
}
|
}
|
||||||
&tree($text, $LocalTree->{$node}, @nodes);
|
&tree($num, $text, $LocalTree->{$node}, @nodes);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if(length($text) > ($maxlen - 5)) {
|
||||||
|
$text = substr($text, 0, ($maxlen -5));
|
||||||
|
}
|
||||||
|
$text = $text . " (" . $NUMC . "#" . $num . $_NUMC . $NOTEC . ")" . $_NOTEC if($text ne "");
|
||||||
push @{$LocalTree->{$node}->{$NoteKey}}, $text;
|
push @{$LocalTree->{$node}->{$NoteKey}}, $text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1402,3 +1488,4 @@ sub print_tree {
|
|||||||
&print_tree($hashref->{$subnotes[$index]},($index == $#subnotes?"$prefix ":"$prefix| "));
|
&print_tree($hashref->{$subnotes[$index]},($index == $#subnotes?"$prefix ":"$prefix| "));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user