diff options
| author | Sadeep Madurange <sadeep@asciimx.com> | 2026-03-13 22:02:51 +0800 |
|---|---|---|
| committer | Sadeep Madurange <sadeep@asciimx.com> | 2026-03-13 22:02:51 +0800 |
| commit | 547c70a838b9fa635d7cc3d8ebced2258670b0db (patch) | |
| tree | 4311aedcbf9b20a8bb7bf8d2e4da6ae933cb7c2d | |
| parent | 0ff09a37a5cbb984c850f5899c93abe07ca85ff4 (diff) | |
| download | cvn-547c70a838b9fa635d7cc3d8ebced2258670b0db.tar.gz | |
Status command.
| -rw-r--r-- | vcx | 53 |
1 files changed, 36 insertions, 17 deletions
@@ -4,30 +4,49 @@ use strict; use warnings; use File::Path qw(make_path); +use constant VCX_DIR => '.vcx'; +use constant BASE_DIR => VCX_DIR . '/bse'; +use constant OBJ_DIR => VCX_DIR . '/obj'; +use constant TMP_DIR => VCX_DIR . '/tmp'; + my $cmd = $ARGV[0] // ''; if ($cmd eq 'init') { - init_repo(); + init_repo(); +} elsif ($cmd eq 'status') { + run_status(); } else { - print "Usage: $0 [command]\n"; - exit 1; + print "Usage: $0 [init|status]\n"; + exit 1; } sub init_repo { - my @dirs = ( - '.vcx/obj', - '.vcx/bse', - '.vcx/tmp' - ); - - foreach my $dir (@dirs) { - if (!-d $dir) { - make_path($dir); - print "Created: $dir\n"; - } - } - - print "Repository ready\n"; + my @dirs = (OBJ_DIR, BASE_DIR, TMP_DIR); + foreach my $dir (@dirs) { + if (!-d $dir) { + make_path($dir); + print "Created: $dir\n"; + } + } + print "Repository ready\n"; } +sub run_status { + my $diff_cmd = "diff -x " . VCX_DIR . " -rq " . BASE_DIR . " ."; + $diff_cmd .= " -X .vcxignore" if -e ".vcxignore"; + + my @output = `$diff_cmd`; + + foreach my $line (@output) { + chomp $line; + # Format output + if ($line =~ /^Only in \Q@{[BASE_DIR]}\E: (.+)$/) { + print "[D] $1\n"; + } elsif ($line =~ /^Only in \.: (.+)$/) { + print "[N] $1\n"; + } elsif ($line =~ /^Files \Q@{[BASE_DIR]}\E\/(.+) and \.\/(.+) differ$/) { + print "[M] $1\n"; + } + } +} |
