| 1 | # | ||||||||||||||||||||||||||||
| 2 | # This file is part of App-Cme | ||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||
| 4 | # This software is Copyright (c) 2014-2022 by Dominique Dumont <ddumont@cpan.org>. | ||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||
| 6 | # This is free software, licensed under: | ||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||
| 8 | # The GNU Lesser General Public License, Version 2.1, February 1999 | ||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||
| 10 | # ABSTRACT: Edit the configuration of an application with fuse | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | package App::Cme::Command::fusefs ; | ||||||||||||||||||||||||||||
| 13 | 1 | $App::Cme::Command::fusefs::VERSION = '1.049'; | |||||||||||||||||||||||||||
| 14 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use 5.10.1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use App::Cme -command ; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use base qw/App::Cme::Common/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 1 | ▶ | use Config::Model::ObjTreeScanner; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 0 | ▶ | sub validate_args { | ||||||||||||||||||||||||||
|
Subroutine
validate_args: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 25 | 0 | my ($self, $opt, $args) = @_; | |||||||||||||||||||||||||||
| 26 | 0 | $self->check_unknown_args($args); | |||||||||||||||||||||||||||
| 27 | 0 | $self->process_args($opt,$args); | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 0 | my $has_fuse = eval { require Config::Model::FuseUI; 1; }; | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 0 | ▶ | die "could not load Config::Model::FuseUI. Is Fuse installed ?\n" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | unless $has_fuse; | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 0 | my $fd = $opt->{fuse_dir}; | |||||||||||||||||||||||||||
| 35 | 0 | ▶ | die "Directory $fd does not exists\n" unless -d $fd; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | return; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 0 | ▶ | sub opt_spec { | ||||||||||||||||||||||||||
|
Subroutine
opt_spec: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 41 | 0 | my ( $class, $app ) = @_; | |||||||||||||||||||||||||||
| 42 | return ( | ||||||||||||||||||||||||||||
| 43 | [ | ||||||||||||||||||||||||||||
| 44 | 0 | "fuse-dir=s" => "Directory where the virtual file system will be mounted", | |||||||||||||||||||||||||||
| 45 | {required => 1} | ||||||||||||||||||||||||||||
| 46 | ], | ||||||||||||||||||||||||||||
| 47 | [ "dfuse!" => "debug fuse problems" ], | ||||||||||||||||||||||||||||
| 48 | [ "dir-char=s" => "string to replace '/' in configuration parameter names"], | ||||||||||||||||||||||||||||
| 49 | [ "backup:s" => "Create a backup of configuration files before saving." ], | ||||||||||||||||||||||||||||
| 50 | $class->cme_global_options, | ||||||||||||||||||||||||||||
| 51 | ); | ||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub usage_desc { | ||||||||||||||||||||||||||
|
Subroutine
usage_desc: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 55 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 56 | 0 | my $desc = $self->SUPER::usage_desc; # "%c COMMAND %o" | |||||||||||||||||||||||||||
| 57 | 0 | return "$desc [application] [file ] -fuse-dir xxx [ -dir-char x ] "; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub description { | ||||||||||||||||||||||||||
|
Subroutine
description: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 61 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 62 | 0 | return $self->get_documentation; | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | ▶ | sub execute { | ||||||||||||||||||||||||||
|
Subroutine
execute: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 66 | 0 | my ($self, $opt, $args) = @_; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | my ($model, $inst, $root) = $self->init_cme($opt,$args); | |||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | my @extra; | |||||||||||||||||||||||||||
| 71 | 0 | ▶ | if (my $dc = $opt->{dir_char}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | 0 | push @extra, dir_char_mockup => $dc; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | my $fuse_dir = $opt->{fuse_dir}; | |||||||||||||||||||||||||||
| 76 | 0 | print "Mounting config on $fuse_dir in background.\n", | |||||||||||||||||||||||||||
| 77 | "Use command 'fusermount -u $fuse_dir' to unmount\n"; | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | my $ui = Config::Model::FuseUI->new( | |||||||||||||||||||||||||||
| 80 | root => $root, | ||||||||||||||||||||||||||||
| 81 | mountpoint => $fuse_dir, | ||||||||||||||||||||||||||||
| 82 | @extra, | ||||||||||||||||||||||||||||
| 83 | ); | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | # now fork | ||||||||||||||||||||||||||||
| 87 | 0 | my $pid = fork; | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | ▶ | if ( defined $pid and $pid == 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $pid and $pid == 0
MC/DC0%0/2
defined $pid and $pid == 0
defined $pid
$pid == 0
Truth table0%0/3
A and B
A= defined $pidB= $pid == 0
| |||||||||||||||||||||||||||||
| 90 | # child process, just run fuse and wait for exit | ||||||||||||||||||||||||||||
| 91 | 0 | $ui->run_loop( debug => $opt->{fuse_debug} ); | |||||||||||||||||||||||||||
| 92 | 0 | $self->save($inst,$opt); | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | # parent process simply exits | ||||||||||||||||||||||||||||
| 96 | 0 | return; | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 1 | 1; | |||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | __END__ | ||||||||||||||||||||||||||||