App-Dochazka-CLI

 view release on metacpan or  search on metacpan

bin/dochazka-cli  view on Meta::CPAN



=head1 SYNOPSIS

Assuming Dochazka REST server is running on port 5000:

    $ dochazka-cli http://localhost:5000
    Loading configuration files from /usr/lib/perl5/site_perl/5.20.1/auto/share/dist/App-Dochazka-CLI
    Authenticating to server at http://localhost:5000
    Username: 
    Server is alive
    Dochazka(2015-03-11) root ADMIN>

This is the Dochazka command-line interface (CLI). Options:

    --debug     -d      Make parser display debug messages
    --help      -h      Get help
    --noauth    -n      Omit authentication
    --password  -p      Specify password
    --sitedir   -s      Specify sitedir
    --user      -u      Specify username

bin/dochazka-cli  view on Meta::CPAN

        if ( $status->text =~ m/Internal auth failed/ ) {
            print "Authentication failed.\n";
            exit;
        }

        # some other scenario?
        print $status->code . ' (' . $status->level . ') ' . $status->text . "\n";
        print "Response: " . Dumper( $status->payload ) . "\n";
        exit;
    } else {
        print "Server is alive\n";
    }
}


# paraphrased from https://metacpan.org/source/HAYASHI/Term-ReadLine-Gnu-1.26/eg/fileman
sub initialize_readline {
    my $term = new Term::ReadLine 'dochazka-cli';
    $term->Attribs->{completion_function} = \&dochazka_cli_completion;
    return $term;
}

lib/App/Dochazka/CLI/Testers.pm  view on Meta::CPAN


You should now be able to start the CLI and login as "demo" with password
"demo":

    $ dochazka-cli -u demo -p demo
    Loading configuration files from
    /usr/lib/perl5/vendor_perl/5.18.2/auto/share/dist/App-Dochazka-CLI
    Cookie jar: /root/.cookies.txt
    URI base http://localhost:5000 set from site configuration
    Authenticating to server at http://localhost:5000 as user root
    Server is alive
    Dochazka(2016-01-12) demo PASSERBY>

Exit the CLI by issuing the C<exit> command:

    Dochazka(2016-01-12) demo PASSERBY> exit
    $

Congratulations! You have passed the first test.


lib/App/Dochazka/CLI/Testers.pm  view on Meta::CPAN

The username and password need not be specified on the command line.
Try it this way:

    $ dochazka-cli
    Loading configuration files from /usr/lib/perl5/vendor_perl/5.18.2/auto/share/dist/App-Dochazka-CLI
    Cookie jar: /root/.cookies.txt
    URI base http://localhost:5000 set from site configuration
    Username: root
    Authenticating to server at http://localhost:5000 as user root
    Password: 
    Server is alive
    Dochazka(2016-01-12) root ADMIN>

=head2 List employees

A list of all employees in the database can be obtained using the C<employee
list> command, which is documented at L<App::Dochazka::CLI::Guide|"Get list of
employees">:

    Dochazka(2016-01-12) root ADMIN> employee list

lib/App/Dochazka/CLI/Testers.pm  view on Meta::CPAN


    New password      : <type george>
    New password again: <type george again>
    Password changed

Now you can log in with credentials C<george/george>:

    $ dochazka-cli -u george -p george
    ...
    Authenticating to server at http://localhost:5000 as user george
    Server is alive
    Dochazka(2016-01-27) george PASSERBY>




=head1 SESSION 3: EMPLOYEE PRIVILEGE HISTORY

Before you do anything, L<make sure the server is running|"Start the server">.


lib/App/Dochazka/CLI/Testers.pm  view on Meta::CPAN

    EOF


=head2 Log in as the test employee

This just demonstrates that the test employee can log in.

    $ dochazka-cli -u george -p george
    ...
    Authenticating to server at http://localhost:5000 as user george
    Server is alive
    Dochazka(2016-01-27) george PASSERBY>


=head2 Concepts (Dochazka prompt, employee priv levels)

Let's review the information presented in the prompt:

=over

=item Prompt date in parentheses (defaults to current date)



( run in 0.799 second using v1.01-cache-2.11-cpan-df04353d9ac )