Skip to content

Commit

Permalink
for files
Browse files Browse the repository at this point in the history
  • Loading branch information
zentooo committed Sep 16, 2010
1 parent 8028d5c commit 0654718
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 30 deletions.
15 changes: 9 additions & 6 deletions README
Expand Up @@ -5,11 +5,14 @@ NAME
SYNOPSIS
viyond search neocomplcache - search and install vim plugin
viyond list - list all installed vim plugins with their numbers
viyond remove neocomplcache - remove existing plugin
viyond remove 1 - remove existing plugin with listed number
viyond remove -all - remove all existing plugins
viyond upgrade - upgrade all existing plugins
viyond upgrade neocomplcache - upgrade specified plugin
viyond remove neocomplcache - remove installed plugin
viyond remove 1 - remove installed plugin with listed number
viyond remove -all - remove all installed plugins
viyond files neocomplcache - show installed files of installed plugin
viyond files 1 - show installed files of installed plugin with listed number
viyond upgrade - upgrade all installed plugins
viyond upgrade neocomplcache - upgrade installed plugin
viyond upgrade 1 - upgrade installed plugin with listed number
viyond add - execute 'git add' after chdir to .vim and .viyond. Ignores .vim/view and .viyond/repos

DESCRIPTION
Expand Down Expand Up @@ -38,5 +41,5 @@ LICENSE

TODO
* ignore .so or .dll with add subcommand, not replace files if no
upgrade found, upgrade with listed numbers
upgrade found, viyond fav(gae?), viyond page(browser setting)

15 changes: 9 additions & 6 deletions lib/Viyond.pm
Expand Up @@ -23,11 +23,14 @@ Viyond - Vim plugin manager which uses github as repository. It's still experime
viyond search neocomplcache - search and install vim plugin
viyond list - list all installed vim plugins with their numbers
viyond remove neocomplcache - remove existing plugin
viyond remove 1 - remove existing plugin with listed number
viyond remove -all - remove all existing plugins
viyond upgrade - upgrade all existing plugins
viyond upgrade neocomplcache - upgrade specified plugin
viyond remove neocomplcache - remove installed plugin
viyond remove 1 - remove installed plugin with listed number
viyond remove -all - remove all installed plugins
viyond files neocomplcache - show installed files of installed plugin
viyond files 1 - show installed files of installed plugin with listed number
viyond upgrade - upgrade all installed plugins
viyond upgrade neocomplcache - upgrade installed plugin
viyond upgrade 1 - upgrade installed plugin with listed number
viyond add - execute 'git add' after chdir to .vim and .viyond. Ignores .vim/view and .viyond/repos
=head1 DESCRIPTION
Expand Down Expand Up @@ -60,7 +63,7 @@ it under the same terms as Perl itself.
=over 4
=item * ignore .so or .dll with add subcommand, not replace files if no upgrade found, upgrade with listed numbers
=item * ignore .so or .dll with add subcommand, not replace files if no upgrade found, viyond fav(gae?), viyond page(browser setting)
=back
Expand Down
18 changes: 3 additions & 15 deletions lib/Viyond/Action/Remove.pm
Expand Up @@ -17,24 +17,12 @@ use feature qw/say/;
my $vimfiles_path = Viyond::Config->get_value('vimfiles_path');

sub remove {
my ($class, $name) = @_;
my ($class, $query) = @_;

my @repo_ids;
my $metadata = Viyond::InstallData::Metadata->load_all;
my $repo_ids = Viyond::InstallData::Metadata->find($query);

if ( is_string $name && $name !~ /\d+/ ) {
@repo_ids = grep /^$name-repo-\w+$/, keys %$metadata;
}
elsif ( 1 <= $name && $name <= scalar keys %$metadata ) {
@repo_ids = ([keys %$metadata]->[$name - 1]);
}

if ( scalar @repo_ids == 0 ) {
say "we cannot find the vim plugin named $name";
return;
}

for my $repo_id (@repo_ids) {
for my $repo_id (@$repo_ids) {
say "will remove $repo_id ...";

my $repo_path = Viyond::Config->get_value('viyond_path') . "/repos/$repo_id";
Expand Down
8 changes: 5 additions & 3 deletions lib/Viyond/Action/Upgrade.pm
Expand Up @@ -15,12 +15,14 @@ use feature qw/say/;


sub upgrade {
my ($class, $name) = @_;
my ($class, $query) = @_;

my $metadata = Viyond::InstallData::Metadata->load_all;
my $repo_ids = Viyond::InstallData::Metadata->find($query);

my @repo_ids = grep /^$name/, keys %$metadata;
for my $repo_id (@$repo_ids) {
say "will upgrade $repo_id ...";

for my $repo_id (@repo_ids) {
my $repo_path = Viyond::Config->get_value('viyond_path') . "/repos/$repo_id";

Viyond::Action::Remove->remove_vimfiles($repo_id);
Expand Down
34 changes: 34 additions & 0 deletions lib/Viyond/Command/Files.pm
@@ -0,0 +1,34 @@
package Viyond::Command::Files;

use strict;
use warnings;

use Viyond -command;

use Viyond::InstallData::Metadata;
use Viyond::InstallData::Filelog;

use Path::Class;
use feature qw/say/;

my $vimfiles_path = Viyond::Config->get_value('vimfiles_path');

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

my $repo_ids = Viyond::InstallData::Metadata->find($args->[0]);

for my $repo_id (@$repo_ids) {
my $files = Viyond::InstallData::Filelog->load($repo_id);

for my $file (@$files) {
say file("$vimfiles_path/$file")->cleanup;
}
}
}

sub abstract {
"show installed files of specified plugin";
}

1;
23 changes: 23 additions & 0 deletions lib/Viyond/InstallData/Metadata.pm
Expand Up @@ -6,7 +6,9 @@ use warnings;
use Viyond::Config;
use Path::Class;
use JSON;
use Data::Util qw/:check/;
use Carp;
use feature qw/say/;

my $metadata_file = Viyond::Config->get_value('viyond_path') . '/metadata.json';

Expand All @@ -16,6 +18,27 @@ sub load_all {
return decode_json(file($metadata_file)->slurp);
}

sub find {
my ($class, $query) = @_;

my $metadata = $class->load_all();
my @repo_ids;

if ( is_string $query && $query !~ /\d+/ ) {
@repo_ids = grep /^$query-repo-\w+$/, keys %$metadata;
}
elsif ( 1 <= $query && $query <= scalar keys %$metadata ) {
@repo_ids = ([keys %$metadata]->[$query - 1]);
}

if ( scalar @repo_ids == 0 ) {
say "we cannot find the vim plugin with given query";
exit;
}

return \@repo_ids;
}

sub add_entry {
my ($class, $git_uri, $repository) = @_;
my $canonical_name = "$repository->{name}-$repository->{id}";
Expand Down

0 comments on commit 0654718

Please sign in to comment.