forked from nitrogen/nitrogen
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmake_plugin
executable file
·55 lines (42 loc) · 1.13 KB
/
make_plugin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/perl
use strict;
use warnings;
use File::Basename;
use File::Copy;
sub main {
my ($app, @files) = @_;
my $orig_dir=`pwd`;
chomp($orig_dir);
print "Creating plugins: $app\n";
mkdir "../$app";
chdir "../$app";
print "...Generating base files\n";
system("$orig_dir/rebar create-lib libid=$app");
print "...Removing default $app.erl\n";
unlink("src/$app.erl");
print "...Adding nitrogen.plugin\n";
system("touch nitrogen.plugin");
print "...creating include directory\n";
mkdir "include";
for(@files) {
my ($base,$path,$ext) = fileparse($_);
my $file = "src/$base$ext";
print "...moving $base$ext to $file\n";
move("$orig_dir/$_", $file);
}
print "...creating blank records.hrl\n";
system("touch include/records.hrl");
print "$app initialized.\nNext Step: copy the element records into $app/include/records.hrl\n\n";
}
if($#ARGV == -1) {
print "Usage: $0 app_name file1.erl,file2.erl,...\n";
print " or\n";
print " $0 file1.erl\n";
}elsif($#ARGV==0) {
my $file = $ARGV[0];
my $basename = basename($file);
(my $app = $basename) =~ s/\.[^.]+$//;
&main($app, $file);
}else{
&main(@ARGV);
}