commit 507f82ddcbb6c812d5d6e83ebddec653d919f1ec
parent f0a5b6ad46fee62a151e6813ae59d837b42d6062
Author: lash <dev@holbrook.no>
Date: Tue, 1 Oct 2024 02:15:20 +0100
WIP complete gen base config tool with refactored args envs
Diffstat:
M | Bluto/Cmd.pm | | | 18 | +++++++++++++++++- |
M | bluto.pl | | | 64 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- |
2 files changed, 77 insertions(+), 5 deletions(-)
diff --git a/Bluto/Cmd.pm b/Bluto/Cmd.pm
@@ -8,7 +8,7 @@ use File::Path qw/make_path/;
use Bluto::SemVer;
use YAML::Tiny;
-use Bluto::Log qw/debug/;
+use Bluto::Log qw/debug error/;
my $force_version = undef;
@@ -68,6 +68,10 @@ sub process_param {
$env{version} = SemVer->new($env{version});
}
+ if (defined $env{src_dir}) {
+ make_path($env{src_dir});
+ }
+
foreach my $k (keys %env) {
my $v = $env{$k};
if (defined $v) {
@@ -83,4 +87,16 @@ sub get_param {
return $env{$k};
}
+sub base_config_path {
+ return File::Spec->catfile($env{src_dir}, 'bluto.yml');
+}
+
+sub release_config_path {
+ if (!defined $env{version}) {
+ error("release config path does not exist, version not set");
+ return undef;
+ }
+ return File::Spec->catfile($env{src_dir}, '.yml');
+}
+
1;
diff --git a/bluto.pl b/bluto.pl
@@ -10,10 +10,66 @@ use lib (dirname(abs_path($0)));
use Bluto::Cmd;
-Bluto::Cmd::register_param("version", undef, "version", undef);
+#Bluto::Cmd::register_param("version", undef, "version", undef);
+Bluto::Cmd::register_param("name", undef, "name", undef);
+Bluto::Cmd::register_param("summary", undef, "summary", undef);
+my $usr = $ENV{LOGNAME} || $ENV{USER} || getpwuid($<);
+Bluto::Cmd::register_param("maintainer", $usr, undef, undef);
+
Bluto::Cmd::process_param();
-my $v = Bluto::Cmd::get_param("version");
-if (!defined $v) {
- Bluto::Cmd::croak($v);
+#my $v = Bluto::Cmd::get_param("version");
+#if (!defined $v) {
+# Bluto::Cmd::croak($v);
+#}
+
+my $name = Bluto::Cmd::get_param('name');
+my $slug;
+if (defined $name) {
+ my $slug = lc();
+ $slug =~ y/ /_/;
+ $slug =~ s/[^a-zA-Z0-9_]//g;
}
+
+my $yc = {
+ name => $name,
+ slug => $slug,
+ summary => Bluto::Cmd::get_param('summary'),
+ license => "",
+ copyright => "",
+ tech => "",
+ vcs => {
+ tag_prefix => "v",
+ },
+ sign => {
+ rsa => "",
+ ed22519 => "",
+ secp256k1 => "",
+ },
+ fund => {
+ btc => "",
+ eth => "",
+ monero => "",
+ },
+ locate => {
+ www => [],
+ rel => [],
+ vcs => [],
+ tgzbase => [],
+ },
+ author => {
+ name => "",
+ email => "",
+ pgp => "",
+ },
+ maintainer => {
+ name => Bluto::Cmd::get_param('maintainer'),
+ email => "",
+ pgp => "",
+ },
+};
+
+my $yo = YAML::Tiny->new($yc);
+#my $fn = File::Spec->catfile($env{src_dir}, 'bluto.yml');
+my $fn = Bluto::Cmd::base_config_path();
+$yo->write($fn);