App-EmacsLockfileUtils

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

LICENSE
MANIFEST
META.json
META.yml
Makefile.PL
README
dist.ini
lib/App/EmacsLockfileUtils.pm
script/emacs-lockfile-get
script/emacs-lockfile-lock
script/emacs-lockfile-locked
script/emacs-lockfile-unlock
t/00-compile.t
t/author-critic.t
t/author-pod-coverage.t
t/author-pod-syntax.t
weaver.ini

META.json  view on Meta::CPAN

            "name" : "GenPericmdScript emacs-lockfile-get",
            "version" : "0.425"
         },
         {
            "class" : "Dist::Zilla::Plugin::GenPericmdScript",
            "name" : "GenPericmdScript emacs-lockfile-lock",
            "version" : "0.425"
         },
         {
            "class" : "Dist::Zilla::Plugin::GenPericmdScript",
            "name" : "GenPericmdScript emacs-lockfile-locked",
            "version" : "0.425"
         },
         {
            "class" : "Dist::Zilla::Plugin::GenPericmdScript",
            "name" : "GenPericmdScript emacs-lockfile-unlock",
            "version" : "0.425"
         },
         {
            "class" : "Dist::Zilla::Plugin::InsertExecsList",
            "name" : "InsertExecsList",

META.yml  view on Meta::CPAN

    -
      class: Dist::Zilla::Plugin::GenPericmdScript
      name: 'GenPericmdScript emacs-lockfile-get'
      version: '0.425'
    -
      class: Dist::Zilla::Plugin::GenPericmdScript
      name: 'GenPericmdScript emacs-lockfile-lock'
      version: '0.425'
    -
      class: Dist::Zilla::Plugin::GenPericmdScript
      name: 'GenPericmdScript emacs-lockfile-locked'
      version: '0.425'
    -
      class: Dist::Zilla::Plugin::GenPericmdScript
      name: 'GenPericmdScript emacs-lockfile-unlock'
      version: '0.425'
    -
      class: Dist::Zilla::Plugin::InsertExecsList
      name: InsertExecsList
      version: '0.032'
    -

Makefile.PL  view on Meta::CPAN

my %WriteMakefileArgs = (
  "ABSTRACT" => "Utilities related to Emacs-style lock files",
  "AUTHOR" => "perlancar <perlancar\@cpan.org>",
  "CONFIGURE_REQUIRES" => {
    "ExtUtils::MakeMaker" => 0
  },
  "DISTNAME" => "App-EmacsLockfileUtils",
  "EXE_FILES" => [
    "script/emacs-lockfile-get",
    "script/emacs-lockfile-lock",
    "script/emacs-lockfile-locked",
    "script/emacs-lockfile-unlock"
  ],
  "LICENSE" => "perl",
  "NAME" => "App::EmacsLockfileUtils",
  "PREREQ_PM" => {
    "Data::Sah::Compiler::perl::TH::bool" => "0.914",
    "Data::Sah::Compiler::perl::TH::str" => "0.914",
    "Data::Sah::Filter::perl::Path::expand_tilde_when_on_unix" => 0,
    "Data::Sah::Filter::perl::Path::strip_slashes_when_on_unix" => 0,
    "File::Lockfile::Emacs" => 0,

README  view on Meta::CPAN

    This document describes version 0.001 of App::EmacsLockfileUtils (from
    Perl distribution App-EmacsLockfileUtils), released on 2025-03-13.

DESCRIPTION
    This distributions provides the following command-line utilities:

    *   emacs-lockfile-get

    *   emacs-lockfile-lock

    *   emacs-lockfile-locked

    *   emacs-lockfile-unlock

    which are CLI interface for the functions in the File::Lockfile::Emacs.

HOMEPAGE
    Please visit the project's homepage at
    <https://metacpan.org/release/App-EmacsLockfileUtils>.

SOURCE

dist.ini  view on Meta::CPAN

[GenPericmdScript / GenPericmdScript emacs-lockfile-get]
url=/File/Lockfile/Emacs/emacs_lockfile_get
read_config=0
read_env=0

[GenPericmdScript / GenPericmdScript emacs-lockfile-lock]
url=/File/Lockfile/Emacs/emacs_lockfile_lock
read_config=0
read_env=0

[GenPericmdScript / GenPericmdScript emacs-lockfile-locked]
url=/File/Lockfile/Emacs/emacs_lockfile_locked
read_config=0
read_env=0

[GenPericmdScript / GenPericmdScript emacs-lockfile-unlock]
url=/File/Lockfile/Emacs/emacs_lockfile_unlock
read_config=0
read_env=0

[InsertExecsList]

lib/App/EmacsLockfileUtils.pm  view on Meta::CPAN

=head1 DESCRIPTION

This distributions provides the following command-line utilities:

=over

=item * L<emacs-lockfile-get>

=item * L<emacs-lockfile-lock>

=item * L<emacs-lockfile-locked>

=item * L<emacs-lockfile-unlock>

=back

which are CLI interface for the functions in the L<File::Lockfile::Emacs>.

=head1 HOMEPAGE

Please visit the project's homepage at L<https://metacpan.org/release/App-EmacsLockfileUtils>.

script/emacs-lockfile-lock  view on Meta::CPAN


B<emacs-lockfile-lock> B<L<--version|/"--version, -v">> (or B<L<-v|/"--version, -v">>)

B<emacs-lockfile-lock> [B<L<--force|/"--force, -f">>|B<L<-f|/"--force, -f">>|B<L<--no-force|/"--force, -f">>|B<L<--noforce|/"--force, -f">>] [B<L<--format|/"--format=s">>=I<name>|B<L<--json|/"--json">>] [B<L<--(no)naked-res|/"--naked-res">>] [B<L<--p...

=head1 DESCRIPTION

Will return 412 if target file does not exist (unless C<force> option is set to
true, in which case we proceed to locking anyway).

Will return 304 if target file is already locked using Emacs-style lockfile by
the same process as us.

Will return 409 if target file is already locked using Emacs-style lockfile by
another process (unless when C<force> option is set to true, in which case will
take over the lock). Note that there are race conditions when using the C<force>
option (between checking that the lockfile, unlinking it, and creating our own).
It is not recommended to use the C<force> option.

Will return 500 if there's an error in reading the lockfile.

Will return 412 if we are not the same process that locks the file (unless
C<force> option is set to true, in which case we proceed to unlocking anyway).

script/emacs-lockfile-locked  view on Meta::CPAN

#!perl

# Note: This script is a CLI for Riap function /File/Lockfile/Emacs/emacs_lockfile_locked
# and generated automatically using Perinci::CmdLine::Gen version 0.502

use 5.010001;
use strict;
use warnings;

use Perinci::CmdLine::Any;

our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2025-03-13'; # DATE
our $DIST = 'App-EmacsLockfileUtils'; # DIST
our $VERSION = '0.001'; # VERSION

my $cmdline = Perinci::CmdLine::Any->new(
    url => "/File/Lockfile/Emacs/emacs_lockfile_locked",
    program_name => "emacs-lockfile-locked",
    read_config => 0,
    read_env => 0,
);

$cmdline->run;

# ABSTRACT: Check whether a target file is locked using Emacs-style lockfile
# PODNAME: emacs-lockfile-locked

__END__

=pod

=encoding UTF-8

=head1 NAME

emacs-lockfile-locked - Check whether a target file is locked using Emacs-style lockfile

=head1 VERSION

This document describes version 0.001 of emacs-lockfile-locked (from Perl distribution App-EmacsLockfileUtils), released on 2025-03-13.

=head1 SYNOPSIS

B<emacs-lockfile-locked> B<L<--help|/"--help, -h, -?">> (or B<L<-h|/"--help, -h, -?">>, B<L<-?|/"--help, -h, -?">>)

B<emacs-lockfile-locked> B<L<--version|/"--version, -v">> (or B<L<-v|/"--version, -v">>)

B<emacs-lockfile-locked> [B<L<--by-us|/"--by-us">>|B<L<--no-by-us|/"--by-us">>|B<L<--noby-us|/"--by-us">>] [B<L<--format|/"--format=s">>=I<name>|B<L<--json|/"--json">>] [B<L<--(no)naked-res|/"--naked-res">>] [B<L<--page-result|/"--page-result">>[=I<p...

=head1 OPTIONS

C<*> marks required options.

=head2 Main options

=over

=item B<--by-us>

script/emacs-lockfile-locked  view on Meta::CPAN


=head1 COMPLETION

This script has shell tab completion capability with support for several
shells.

=head2 bash

To activate bash completion for this script, put:

 complete -C emacs-lockfile-locked emacs-lockfile-locked

in your bash startup (e.g. F<~/.bashrc>). Your next shell session will then
recognize tab completion for the command. Or, you can also directly execute the
line above in your shell to activate immediately.

It is recommended, however, that you install modules using L<cpanm-shcompgen>
which can activate shell completion for scripts immediately.

=head2 tcsh

To activate tcsh completion for this script, put:

 complete emacs-lockfile-locked 'p/*/`emacs-lockfile-locked`/'

in your tcsh startup (e.g. F<~/.tcshrc>). Your next shell session will then
recognize tab completion for the command. Or, you can also directly execute the
line above in your shell to activate immediately.

It is also recommended to install L<shcompgen> (see above).

=head2 other shells

For fish and zsh, install L<shcompgen> as described above.

script/emacs-lockfile-unlock  view on Meta::CPAN


my $cmdline = Perinci::CmdLine::Any->new(
    url => "/File/Lockfile/Emacs/emacs_lockfile_unlock",
    program_name => "emacs-lockfile-unlock",
    read_config => 0,
    read_env => 0,
);

$cmdline->run;

# ABSTRACT: Unlock a file locked with Emacs-style lockfile
# PODNAME: emacs-lockfile-unlock

__END__

=pod

=encoding UTF-8

=head1 NAME

emacs-lockfile-unlock - Unlock a file locked with Emacs-style lockfile

=head1 VERSION

This document describes version 0.001 of emacs-lockfile-unlock (from Perl distribution App-EmacsLockfileUtils), released on 2025-03-13.

=head1 SYNOPSIS

B<emacs-lockfile-unlock> B<L<--help|/"--help, -h, -?">> (or B<L<-h|/"--help, -h, -?">>, B<L<-?|/"--help, -h, -?">>)

B<emacs-lockfile-unlock> B<L<--version|/"--version, -v">> (or B<L<-v|/"--version, -v">>)

script/emacs-lockfile-unlock  view on Meta::CPAN

B<emacs-lockfile-unlock> [B<L<--force|/"--force, -f">>|B<L<-f|/"--force, -f">>|B<L<--no-force|/"--force, -f">>|B<L<--noforce|/"--force, -f">>] [B<L<--format|/"--format=s">>=I<name>|B<L<--json|/"--json">>] [B<L<--(no)naked-res|/"--naked-res">>] [B<L<-...

=head1 DESCRIPTION

Note that there is a race condition between reading the lockfile and unlinking
it.

Will return 412 if target file does not exist (unless C<force> option is set to
true, in which case we proceed to unlocking anyway).

Will return 304 if target file is not currently locked using Emacs-style
lockfile.

Will return 500 if there's an error in reading the lockfile.

Will return 412 if we are not the same process that locks the file (unless
C<force> option is set to true, in which case we proceed to unlocking anyway).

Will return 500 if there's an error in removing the lockfile.

Will return 200 if everything goes ok.

t/00-compile.t  view on Meta::CPAN


plan tests => 5 + ($ENV{AUTHOR_TESTING} ? 1 : 0);

my @module_files = (
    'App/EmacsLockfileUtils.pm'
);

my @scripts = (
    'script/emacs-lockfile-get',
    'script/emacs-lockfile-lock',
    'script/emacs-lockfile-locked',
    'script/emacs-lockfile-unlock'
);

# no fake home requested

my @switches = (
    -d 'blib' ? '-Mblib' : '-Ilib',
);

use File::Spec;

t/author-critic.t  view on Meta::CPAN

}


use strict;
use warnings;

# this test was generated with Dist::Zilla::Plugin::Test::Perl::Critic::Subset 3.001.006

use Test::Perl::Critic (-profile => "") x!! -e "";

my $filenames = ['lib/App/EmacsLockfileUtils.pm','script/emacs-lockfile-get','script/emacs-lockfile-lock','script/emacs-lockfile-locked','script/emacs-lockfile-unlock'];
unless ($filenames && @$filenames) {
    $filenames = -d "blib" ? ["blib"] : ["lib"];
}

all_critic_ok(@$filenames);



( run in 0.950 second using v1.01-cache-2.11-cpan-49f99fa48dc )