This file is indexed.

/usr/bin/hm is in libnet-hiveminder-perl 0.08-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/env perl
use strict;
use warnings;
use Net::Hiveminder;
use Getopt::Long;
use Pod::Usage;
use File::Temp;

our $CONFFILE = "$ENV{HOME}/.hiveminder";
our $VERSION = 0.01;
our %args;
our @args;
our $hm;
our %config;

our %unaccepted_query = (
    complete_not => 1,
    unaccepted   => 1,
);

our %requests_query = (
    requestor    => "me",
    owner_not    => "me",
    complete_not => 1,
);

terminal();
get_options();
main();

sub main {
    my %commands = (
        list       => \&list_tasks,
        ls         => \&list_tasks,
        todo       => \&list_tasks,
        unaccepted => sub {list_tasks(%unaccepted_query)},
        requests   => sub {list_tasks(%requests_query)},

        add        => sub {$hm->create_task("@ARGV")},
        bd         => \&braindump,
        braindump  => \&braindump,

#        do        => \&do_task,
#        done      => \&do_task,
#        del       => \&del_task,
#        rm        => \&del_task,
#        edit      => \&edit_task,
#        tag       => \&tag_task,
#        accept    => \&accept_task,
#        decline   => \&decline_task,
#        assign    => \&assign_task,
#        hide      => \&hide_task,
#        comment   => \&comment_task,
#        dl        => \&download_textfile,
#        download  => \&download_textfile,
#        ul        => \&upload_textfile,
#        upload    => \&upload_textfile,
       );

    my $command = shift @ARGV || "list";
    $commands{$command} or pod2usage(-message => "Unknown command: $command", -exitval => 2);

    # log in
    $hm = Net::Hiveminder->new(use_config => 1, config_file => $CONFFILE);
    %config = %{ $hm->config };
    canonicalize_options();

    $commands{$command}->();
}

sub terminal {
    my $encoding = eval {
        require Term::Encoding; Term::Encoding::get_encoding();
    } || "utf-8";

    binmode STDOUT, ":encoding($encoding)";
}

sub get_options {
    GetOptions(\%args,
               "tags=s",
               "tag=s@", "group=s",
               "priority|pri=s",
               "due=s",
               "hide=s",
               "help",
               "version",
               "config=s",
    ) or pod2usage(2);

    $CONFFILE = $args{config} if $args{config};

    pod2usage(0) if $args{help};
    if ($args{version}) {
        version();
        exit();
    }
}

sub canonicalize_options {
    $args{priority} &&= $hm->canonicalize_priority($args{priority});

    # the ; is here so Perl interprets it as a codeblock and not a hashref
    @args = map { ; tag => $_ } split ' ', ($args{tags}||'');

    for (qw/group priority due hide/) {
        push @args, $_ => $args{$_}
            if $args{$_};
    }

    return @args;
}

sub list_tasks {
    # if there are any qualifiers, use the generic search instead of todo
    my $method = @_ ? 'get_tasks' : 'todo_tasks';

    push @_, @args;
    print $hm->display_tasks( $hm->$method(@_) ) . "\n";
}

sub braindump {
    my $editor = $ENV{EDITOR}
        or pod2usage(-message => "Need to specify \$EDITOR.",
                     -exitval => 1);

    my $fh = File::Temp->new(UNLINK => 0);
    my $fn = $fh->filename;
    $fh->close;

    # Call the editor with the file as the first arg
    system($editor, $fn);
    $hm->upload_file($fn);
    unlink $fn;
}