bin/kv

Wed, 25 Sep 2024 15:03:13 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Wed, 25 Sep 2024 15:03:13 -0500
changeset 1179
b0a0ba3240b5
parent 1142
dd4f69be5e32
permissions
-rwxr-xr-x

No LSP autostart when read-only

I think nvim actually threw out 'view' argc detection, I just use -R and alias
view to it.

1115
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1 #!/usr/bin/env perl
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2 use v5.32;
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
3 use Fcntl;
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
4 use AnyDBM_File;
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
5
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
6 my ($filename, $method, @args) = @ARGV;
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
7
1142
dd4f69be5e32 Add perl ver to sdbm filename due to breakage
Meredith Howard <mhoward@roomag.org>
parents: 1115
diff changeset
8 $filename .= ".$]";
dd4f69be5e32 Add perl ver to sdbm filename due to breakage
Meredith Howard <mhoward@roomag.org>
parents: 1115
diff changeset
9
1115
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
10 tie my %h, 'AnyDBM_File', $filename, O_RDWR|O_CREAT, 0660
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
11 or die "tie $filename: $!";
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
12
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
13 $, = "\n";
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
14
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
15 say main->can($method)->(@args);
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
16
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
17 sub get { $h{+shift} }
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
18 sub set { $h{$_[0]} = $_[1] and exit }
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
19 sub del { delete $h{+shift} }
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
20
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
21 sub touch { $h{+shift} = time and exit }
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
22 sub age { time - $h{+shift} }
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
23 sub age_days { int(age(shift) / 86_400) }
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
24 sub age_days_gt { exit 0+!(age_days(shift) > shift) }
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
25
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
26 sub keys { keys %h }
15ca9da8cd59 use distinct db for update checks
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
27 sub dump { map { "$_ = $h{$_}" } keys %h }

mercurial