Print hashed objects
This commit is contained in:
13
ugit/cli.py
13
ugit/cli.py
@@ -1,6 +1,8 @@
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
from . import data
|
||||
|
||||
|
||||
@@ -18,6 +20,10 @@ def parse_args():
|
||||
init_parser = commands.add_parser("init")
|
||||
init_parser.set_defaults(func=init)
|
||||
|
||||
cat_file_parser = commands.add_parser("cat-file")
|
||||
cat_file_parser.set_defaults(func=cat_file)
|
||||
cat_file_parser.add_argument("object")
|
||||
|
||||
hash_object_parser = commands.add_parser("hash-object")
|
||||
hash_object_parser.set_defaults(func=hash_object)
|
||||
hash_object_parser.add_argument("file")
|
||||
@@ -33,3 +39,8 @@ def init(args):
|
||||
def hash_object(args):
|
||||
with open(args.file, "rb") as f:
|
||||
print(data.hash_object(f.read()))
|
||||
|
||||
|
||||
def cat_file(args):
|
||||
sys.stdout.flush()
|
||||
sys.stdout.buffer.write(data.get_object(args.object))
|
||||
|
||||
Reference in New Issue
Block a user