Skip to content
Browse files

Added --name option for STDIN

  • Loading branch information...
1 parent 8664304 commit eb700f7b30ad85a4983cfb34bb2eee28b80d1ff5 @miyagawa committed
Showing with 13 additions and 11 deletions.
  1. +4 −3 README.mkdn
  2. +9 −8 gistp
View
7 README.mkdn
@@ -13,9 +13,10 @@ Set global git config as explained in [github account page](http://github.com/ac
## Synopsis
- echo "foo" | gistp post a new gist (no name set)
- gistp file1 file2 ... post a new gist (with names, can be multiple)
- gistp --private file1 post a new private gist
+ echo "foo" | gistp post a new gist (no name set)
+ echo "foo" | gistp --name "foo.txt" post a new gist (with a name)
+ gistp file1.rb file2.pl ... post a new gist (with names, can be multiple)
+ gistp --private file1.txt post a new private gist
## Difference with gist and gisty
View
17 gistp
@@ -8,7 +8,7 @@ use File::Slurp qw(slurp);
use Pod::Usage;
my %options;
-GetOptions(\%options, "--private", "--help");
+GetOptions(\%options, "--name=s", "--private", "--help");
run(\%options, @ARGV);
@@ -19,7 +19,7 @@ sub run {
pod2usage(0);
}
- my @files = setup_files(@args);
+ my @files = setup_files($opts, @args);
my %fields;
my $i = 1;
@@ -37,19 +37,19 @@ sub run {
}
sub setup_files {
- my @args = @_;
+ my($opts, @args) = @_;
my @files;
- if (@args > 0) {
+ if (@args == 0 or $args[0] eq '-') {
+ my $content = join '', <STDIN>;
+ @files = ({ name => $opts->{name} || '', content => $content });
+ } else {
for my $arg (@args) {
push @files, {
name => $arg,
content => scalar slurp($arg),
};
}
- } else {
- my $content = join '', <STDIN>;
- @files = ({ name => '', content => $content });
}
return @files;
@@ -111,9 +111,10 @@ gistp - Uploads and clone new paste to gist
=head1 SYNOPSIS
- echo foo | gistp
gistp code.pl
gistp --private foo.rb bar.txt
+ echo foo | gistp
+ ls -l | gistp --name ls-output.txt
=head1 DESCRIPTION

0 comments on commit eb700f7

Please sign in to comment.
Something went wrong with that request. Please try again.