commit c0c671442a12c8ba30755a1e7db5e7c5756186cd
Author: Spesk1 <spesk@pm.me>
Date: Tue May 21 14:32:45 2019 -0400
Updated README and added arg parsing sub
diff --git a/README.md b/README.md
index 4a462eb..f07cca8 100644
--- a/README.md
+++ b/README.md
@@ -15,6 +15,9 @@ Features:
--configure-local-user
* configure local user in .git/config
+--add-upstream
+* append upstream config to fork config
+
Stuff to fix:
* enforce req. of logging object in all relevant Git.pm subs
-* sub in sg for sane processing/resolution of arguments (currently dangerous if passing all/poorly ordered opts)
+* multipule TODO:'s in various files
diff --git a/sg b/sg
index 1bbd6a0..506eac3 100755
--- a/sg
+++ b/sg
@@ -104,8 +104,46 @@ if ( scalar keys %args < 1 ) {
printHelp();
}
+###
+# TODO: This args processing is better and more predictable than it was, bit there is still
+# likely a lot of room for improvement...
+###
+
+sub parseArgs {
+
+ if ( defined $args{'view'} && scalar keys %args > 1 ) {
+ print "Can't pass other args with --view\n";
+ exit 1;
+ }
+
+ if ( defined $args{'dump-config'} && scalar keys %args > 1 ) {
+ print "Can't pass other args with --dump-config\n";
+ exit 1;
+ }
+
+ if ( defined $args{'reset-from-master'} && scalar keys %args > 1 ) {
+ print "Can't pass other args with --reset-from-master\n";
+ exit 1;
+ }
-# This functionality is mainly here to test building out Git.pm, and doesn't really offer anything that regular git doesn't
+ if ( defined $args{'push-all'} ) {
+ foreach my $arg ( keys %args ) {
+ if ( $arg eq "interactive" || $arg eq "commit-msg" || $arg eq "push-all" ) {
+ next;
+ } else {
+ print "Can only pass --interactive and --commit-msg with --push-all\n";
+ exit 1;
+ }
+ }
+ }
+
+
+
+}
+
+parseArgs();
+
+# TODO: This sub could be more concise with a sub to print array refs
if ( defined $args{'view'} ) {
my ( $untrackedRef, $modifiedRef, $addedRef, $deletedRef ) = returnState($logger);
my $refs = shellex("$gitCmd show-ref",$logger);
@@ -155,11 +193,6 @@ if ( defined $args{'view'} ) {
}
}
-###
-# TODO: This args processing is dangerous and incomplete, need to write an args processor function
-###
-
-# This functionality is mainly here to test building out Git.pm, and doesn't really offer anything that regular git doesn't
if ( defined $args{'push-all'} ) {
my ( $untrackedRef, $modifiedRef ) = returnState($logger);