aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-07-02 15:10:45 +0800
committer魏曹先生 <1992414357@qq.com>2026-07-02 15:10:45 +0800
commit9fcb61d5c0f3cf3c313bac35fe85b0636e850204 (patch)
tree53e84db2dcd4b1c57bf2ecfe6181e2c7aa944426
parent1f889d429133f920411db8ea1b88a68657f79435 (diff)
feat: add sample scripts for Go, Nim, Perl, Ruby, and Zig
-rw-r--r--.run/src/bin/go-script.go24
-rw-r--r--.run/src/bin/nim_script.nim19
-rw-r--r--.run/src/bin/perl-script.pl16
-rw-r--r--.run/src/bin/ruby-script.rb12
-rw-r--r--.run/src/bin/zig-script.zig29
5 files changed, 100 insertions, 0 deletions
diff --git a/.run/src/bin/go-script.go b/.run/src/bin/go-script.go
new file mode 100644
index 0000000..bdc88ef
--- /dev/null
+++ b/.run/src/bin/go-script.go
@@ -0,0 +1,24 @@
+package main
+
+import (
+ "fmt"
+ "os"
+ "strings"
+)
+
+func main() {
+ cwd, _ := os.Getwd()
+ quoted := make([]string, len(os.Args[1:]))
+ for i, a := range os.Args[1:] {
+ quoted[i] = fmt.Sprintf("\"%s\"", a)
+ }
+ args := strings.Join(quoted, ", ")
+
+ fmt.Println()
+ fmt.Println(" Welcome to use `run.sh` / `run.ps1`")
+ fmt.Println()
+ fmt.Println(" > \"Hello World\"")
+ fmt.Printf(" > cwd : \"%s\"\n", cwd)
+ fmt.Printf(" > args : %s\n", args)
+ fmt.Println()
+}
diff --git a/.run/src/bin/nim_script.nim b/.run/src/bin/nim_script.nim
new file mode 100644
index 0000000..12700a9
--- /dev/null
+++ b/.run/src/bin/nim_script.nim
@@ -0,0 +1,19 @@
+#!/usr/bin/env nim
+
+import os
+
+let cwd = getCurrentDir()
+var args = ""
+for i, a in commandLineParams():
+ if i > 0: args.add(", ")
+ args.add("\"")
+ args.add(a)
+ args.add("\"")
+
+echo ""
+echo " Welcome to use `run.sh` / `run.ps1`"
+echo ""
+echo " > \"Hello World\""
+echo " > cwd : \"" & cwd & "\""
+echo " > args : " & args
+echo ""
diff --git a/.run/src/bin/perl-script.pl b/.run/src/bin/perl-script.pl
new file mode 100644
index 0000000..16c4e43
--- /dev/null
+++ b/.run/src/bin/perl-script.pl
@@ -0,0 +1,16 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use Cwd qw(cwd);
+
+my $cwd = cwd();
+my $args = join ", ", map { "\"$_\"" } @ARGV;
+
+print "\n";
+print " Welcome to use `run.sh` / `run.ps1`\n";
+print "\n";
+print " > \"Hello World\"\n";
+print " > cwd : \"$cwd\"\n";
+print " > args : $args\n";
+print "\n";
diff --git a/.run/src/bin/ruby-script.rb b/.run/src/bin/ruby-script.rb
new file mode 100644
index 0000000..82b0d72
--- /dev/null
+++ b/.run/src/bin/ruby-script.rb
@@ -0,0 +1,12 @@
+#!/usr/bin/env ruby
+
+cwd = Dir.pwd
+args = ARGV.map { |a| "\"#{a}\"" }.join(", ")
+
+puts
+puts ' Welcome to use `run.sh` / `run.ps1`'
+puts
+puts ' > "Hello World"'
+puts " > cwd : \"#{cwd}\""
+puts " > args : #{args}"
+puts
diff --git a/.run/src/bin/zig-script.zig b/.run/src/bin/zig-script.zig
new file mode 100644
index 0000000..77e0cee
--- /dev/null
+++ b/.run/src/bin/zig-script.zig
@@ -0,0 +1,29 @@
+const std = @import("std");
+
+pub fn main() !void {
+ var gpa = std.heap.GeneralPurposeAllocator(.{}){};
+ defer _ = gpa.deinit();
+ const allocator = gpa.allocator();
+
+ const cwd = std.fs.cwd().realpathAlloc(allocator, ".") catch "?";
+ defer allocator.free(cwd);
+
+ var args_list = std.ArrayList(u8).init(allocator);
+ defer args_list.deinit();
+
+ const writer = args_list.writer();
+ for (std.os.argv[1..], 0..) |arg, i| {
+ if (i > 0) try writer.writeAll(", ");
+ try writer.print("\"{s}\"", .{std.mem.span(arg)});
+ }
+ const args = args_list.items;
+
+ const stdout = std.io.getStdOut().writer();
+ try stdout.writeAll("\n");
+ try stdout.writeAll(" Welcome to use `run.sh` / `run.ps1`\n");
+ try stdout.writeAll("\n");
+ try stdout.writeAll(" > \"Hello World\"\n");
+ try stdout.print(" > cwd : \"{s}\"\n", .{cwd});
+ try stdout.print(" > args : {s}\n", .{args});
+ try stdout.writeAll("\n");
+}