App-gh

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

          this will clone new repositories only.

        * Understand link to github in fork command (CHORNY)


0.0164  Áù 10/ 2 21:11:39 2010
        * add new command `recent`.
        * update repository with `git pull --rebase --all`

0.0167  Sat 16 Oct 2010 11:47:28 AM JST
        * add upload command
        * --cpan option for upload command to use CPAN::Uploader

README.mkd  view on Meta::CPAN

```bash
    $ gh all perl6 --recursive
```


### import

By using the `import` command, you can import your git
repository to your GitHub account.

You can simply type below line the upload your project:

```bash
    $ gh import
```

To specify remote name for GitHub, you can use `--remote`
option.

```bash
    $ gh import --remote github

completion/bash/gh.sh  view on Meta::CPAN

            gh_commands=$( gh | cut -d- -f1 | sed -e 's/^[ ]*//' )
        fi
        COMPREPLY=( $( compgen -W "$gh_commands" -- $cur ) )
        return 0
    elif (($COMP_CWORD == 2 )); then
        local subcmd=${COMP_WORDS[1]}
        if [[ $subcmd == "fork" || $subcmd == "pull" ]] ; then
            local gh_forks=$(gh network --id)
            COMPREPLY=( $( compgen -W "$gh_forks" -- $cur ) )
            return 0
        elif [[ $subcmd == "upload" ]] ; then
            COMPREPLY=( $( compgen -A file -- $cur ) )
            return 0
        elif [[ $subcmd == "clone" ]] ; then
            local userid=$cur
            userid=$( echo $userid | sed -e 's/\/[0-9a-zA-Z.]*$//')
            repo_list=$( gh list $userid --name )
            COMPREPLY=( $( compgen -W "$repo_list" -- $cur ) )
            return 0
        fi
    fi

lib/App/gh/Command/Upload.pm  view on Meta::CPAN

package App::gh::Command::Upload;
use warnings;
use strict;
use base qw(App::gh::Command);
use Net::GitHub::Upload;
use App::gh::Utils;

=head1 NAME

App::gh::Command::Upload - upload file to github.

=head1 USAGE

    gh upload {file} [{repo}]

    gh upload App-gh.tar.gz

    gh upload App-gh.tar.gz c9s/App-gh

    gh upload App-gh.tar.gz --cpan   # also upload to cpan


=cut


sub options { ( 'c|cpan' => 'cpanupload') }

sub run {
    my ( $self, $file, $repo ) = @_;
	my $gh_id = App::gh->config->github_id;
	my $gh_token = App::gh->config->github_token;

    unless( $gh_id && $gh_token ) {
        die "Github authtoken not found.\n";
    }

    if( $self->{cpanupload} ) {
        print "Uploading file to CPAN.\n";
        $self->cpanupload( $file );
    }

    my $gh = Net::GitHub::Upload->new(
        login => $gh_id,
        token => $gh_token,
    );

    $repo ||= $gh_id . '/' . $self->get_current_repo();
    print "Uploading $file to Github: $repo\n";
    eval {
        $gh->upload(
            repos => $repo,
            file  => $file,
        );
    };
    print $@ . ':' . $! if $@;
    print "Done\n";
}


sub cpanupload {
    my ( $self, $file ) = @_;
    eval {
        use CPAN::Uploader;
    };

    if( $@ ) {
        warn 'Can not use CPAN::Uploader, please install it.';
        return;
    }

lib/App/gh/Command/Upload.pm  view on Meta::CPAN

    if (! $arg{password}) {
        require Term::ReadKey;
        local $| = 1;
        print "PAUSE Password: ";
        Term::ReadKey::ReadMode('noecho');
        chop($arg{password} = <STDIN>);
        Term::ReadKey::ReadMode('restore');
        print "\n";
    }

    CPAN::Uploader->upload_file(
        $file,
        \%arg,
    );

}



1;



( run in 2.623 seconds using v1.01-cache-2.11-cpan-b16cb0d3907 )