summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2026-03-13 22:02:51 +0800
committerSadeep Madurange <sadeep@asciimx.com>2026-03-13 22:02:51 +0800
commit547c70a838b9fa635d7cc3d8ebced2258670b0db (patch)
tree4311aedcbf9b20a8bb7bf8d2e4da6ae933cb7c2d
parent0ff09a37a5cbb984c850f5899c93abe07ca85ff4 (diff)
downloadcvn-547c70a838b9fa635d7cc3d8ebced2258670b0db.tar.gz
Status command.
-rw-r--r--vcx53
1 files changed, 36 insertions, 17 deletions
diff --git a/vcx b/vcx
index aeb62c6..d5baf2c 100644
--- a/vcx
+++ b/vcx
@@ -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";
+ }
+ }
+}