Changeset 86 in bookmarks


Ignore:
Timestamp:
06/04/15 01:01:39 (9 years ago)
Author:
peter
Message:

issue #9: allow bkmk init to specifiy a YAML file to load after creating the database

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bkmk

    r85 r86  
    2626my %action_for = ( 
    2727    init => sub { 
     28        my $src_file = shift; 
    2829        $bookmarks->create_tables; 
     30        load_bookmarks($src_file) if $src_file; 
    2931    }, 
    3032     
     
    6971    load => sub { 
    7072        my ($src_file) = @_; 
    71         my $src_bookmarks = YAML::LoadFile($src_file); 
    72         for my $bookmark (@{ $src_bookmarks }) { 
    73             $bookmarks->add($bookmark); 
    74         } 
     73        load_bookmarks($src_file); 
    7574    }, 
    7675); 
     
    9190    return $mech->title || $uri; 
    9291} 
     92 
     93sub load_bookmarks { 
     94    my $src_file = shift; 
     95    my $src_bookmarks = YAML::LoadFile($src_file); 
     96    for my $bookmark (@{ $src_bookmarks }) { 
     97        $bookmarks->add($bookmark); 
     98    } 
     99} 
Note: See TracChangeset for help on using the changeset viewer.