Browse code
feature: rewrite git-ignore in common-lisp
Showing 1 changed files
... | ... |
@@ -1,31 +1,24 @@ |
1 |
-#!/usr/bin/env python |
|
2 |
-import argparse |
|
1 |
+#!/usr/bin/env sbcl --script |
|
3 | 2 |
|
4 |
-parser = argparse.ArgumentParser() |
|
5 |
-parser.add_argument('files_to_ignore', nargs='*') |
|
6 |
-args = parser.parse_args() |
|
3 |
+(eval-when (:compile-toplevel :load-toplevel :execute) |
|
4 |
+ (require :uiop)) |
|
7 | 5 |
|
8 |
-try: |
|
9 |
- lines = [] |
|
6 |
+(defpackage :fwoar.git-ignore |
|
7 |
+ (:use :cl)) |
|
10 | 8 |
|
11 |
- if args.files_to_ignore != []: |
|
12 |
- lines.extend(args.files_to_ignore) |
|
9 |
+(defparameter *args* |
|
10 |
+ (uiop:command-line-arguments)) |
|
13 | 11 |
|
14 |
- else: |
|
15 |
- lines = [] |
|
16 |
- try: |
|
17 |
- getline = lambda: raw_input('? ').strip() |
|
18 |
- line = getline() |
|
19 |
- while line != '.': |
|
20 |
- lines.append(line) |
|
21 |
- line = getline() |
|
22 |
- except EOFError: |
|
23 |
- pass |
|
24 |
- |
|
25 |
- |
|
26 |
- with open('.gitignore', 'a') as f: |
|
27 |
- for line in lines: |
|
28 |
- print 'ignoring %s' % line |
|
29 |
- print >> f, line |
|
30 |
-except KeyboardInterrupt: |
|
31 |
- pass |
|
12 |
+(with-open-file (s ".gitignore" :direction :output :if-exists :append) |
|
13 |
+ (if *args* |
|
14 |
+ (format s "~{~a~%~}" *args*) |
|
15 |
+ (loop for line = (string-trim '(#\space #\tab #\newline) |
|
16 |
+ (progn (format *query-io* "ignore? ") |
|
17 |
+ (finish-output *query-io*) |
|
18 |
+ (read-line *query-io* nil))) |
|
19 |
+ while (and line |
|
20 |
+ (not (string= line "")) |
|
21 |
+ (not (string= line "."))) |
|
22 |
+ do |
|
23 |
+ (princ line s) |
|
24 |
+ (terpri s)))) |