File: shell.pm

package info (click to toggle)
cme 1.043-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 392 kB
  • sloc: perl: 1,293; makefile: 19; sh: 9
file content (96 lines) | stat: -rw-r--r-- 1,833 bytes parent folder | download | duplicates (4)
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
# ABSTRACT: Edit the configuration of an application with a shell

package App::Cme::Command::shell ;

use strict;
use warnings;
use 5.10.1;

use App::Cme -command ;

use base qw/App::Cme::Common/;

sub validate_args {
    my ($self, $opt, $args) = @_;
    $self->check_unknown_args($args);
    $self->process_args($opt,$args);
    return;
}

sub opt_spec {
    my ( $class, $app ) = @_;
    return ( 
        [ "open-item=s" => "open a specific item of the configuration" ],
        [ "backup:s"  => "Create a backup of configuration files before saving." ],
        [ "bare!"       => "run bare terminal UI"],
        $class->cme_global_options,
    );
}

sub usage_desc {
  my ($self) = @_;
  my $desc = $self->SUPER::usage_desc; # "%c COMMAND %o"
  return "$desc [application] [file ]";
}

sub description {
    my ($self) = @_;
    return $self->get_documentation;
}

sub execute {
    my ($self, $opt, $args) = @_;

    my ($model, $inst, $root) = $self->init_cme($opt,$args);

    $root->deep_check;

    if ($opt->{bare})  {
        require Config::Model::SimpleUI;
        $self->run_shell_ui('Config::Model::SimpleUI', $inst) ;
    }
    else {
        require Config::Model::TermUI;
        $self->run_shell_ui('Config::Model::TermUI', $inst) ;
    }

    return;
}

1;

__END__

=head1 SYNOPSIS

  # simple shell like interface
  cme shell dpkg-copyright

=head1 DESCRIPTION

Edit the configuration with a shell like interface.  See L<Config::Model::TermUI>
for details. This is a shortcut for C<cme edit -ui shell>. See L<App::Cme::Command::shell>.

=head1 Common options

See L<cme/"Global Options">.

=head1 options

=over

=item -open-item

Open a specific item of the configuration when opening the editor

=item -bare

Use Term UI without auto-completion or font enhancements.

=back

=head1 SEE ALSO

L<cme>

=cut