Ticket #779 (closed patch: fixed)

Opened 6 years ago

Last modified 5 years ago

[tools] modify fetch_languages.pl to only fetch a specific language

Reported by: s1n Owned by:
Priority: trivial Milestone:
Component: none Version: trunk
Severity: low Keywords: languages
Cc: Language:
Patch status: applied Platform: all

Description

In some cases, only a specific language is desired (and not all). The following is a patch to allow a --lang option to specify 1 language (i.e. --lang c99):

Index: tools/dev/fetch_languages.pl
===================================================================
--- tools/dev/fetch_languages.pl        (revision 39599)
+++ tools/dev/fetch_languages.pl        (working copy)
@@ -29,8 +29,8 @@
 use Pod::Usage;
 use Cwd;

-my ( $update_flag, $checkout_flag ) = ( 0, 1 );
-GetOptions( 'update' => \$update_flag ) or pod2usage();
+my ( $update_flag, $checkout_flag, $lang_flag ) = ( 0, 1, undef );
+GetOptions( 'lang=s' => \$lang_flag, 'update' => \$update_flag ) or pod2usage();

 my $languages_dir = 'languages';
 mkdir $languages_dir;
@@ -304,6 +304,7 @@
 );

 foreach (@hlls) {
+    next if $lang_flag && $_->{name} ne $lang_flag;
     if ($checkout_flag && ! -d $_->{name}) {
         my @cmd = ( @{ $checkout_cmd{ $_->{scm} } }, $_->{repository}, $_->{name} );
         my $dir = getcwd();

Note this is against r39599.

Change History

Changed 5 years ago by jkeenan

  • keywords languages added
  • patch set to rejected

I applied this patch in my sandbox and then called:

perl tools/dev/fetch_languages.pl bf

... which I subsequently realized was a mistake. I then called:

perl tools/dev/fetch_languages.pl lang=bf

In both cases, the program did not stop at bf. It proceeded to begin downloading c99 and all the other languages.

I infer that the patch cannot be applied as written. s1n, can you revise?

Thank you very much.
kid51

Changed 5 years ago by s1n

This tool uses Getopts::Long, so the correct way to call it would be something like

perl tools/dev/fetch_languages.pl --lang bf

I just tested that again and it functions properly.

Changed 5 years ago by s1n

I meant to say Getopt::Long. There may be other ways to properly interact, so see the  documentation.

Changed 5 years ago by Infinoid

  • status changed from new to closed
  • resolution set to fixed
  • patch changed from rejected to applied

Yes, it needs two hyphens before the lang=<hll>. That seems sane.

Thanks, applied as r39818. I took the liberty of updating the POD to reflect your changes.

Note: See TracTickets for help on using tickets.