Initial commit of xenu-nntp-group
This commit is contained in:
parent
2aaa34e971
commit
d19da96838
1 changed files with 35 additions and 0 deletions
35
bin/xenu-nntp-group
Executable file
35
bin/xenu-nntp-group
Executable file
|
@ -0,0 +1,35 @@
|
||||||
|
#! /usr/bin/env python3
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
from xenu_nntp.config import Config
|
||||||
|
from xenu_nntp.db import Database
|
||||||
|
from xenu_nntp.newsgroup import Newsgroup
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(description='Create new account')
|
||||||
|
parser.add_argument('--config-file', '-f', type=str, help='Specify a configuration file location')
|
||||||
|
parser.add_argument('--created-on', type=str, help='Specify creation date of newsgroup')
|
||||||
|
parser.add_argument('--created-by', type=str, required=True, help='Print messages when importing files and messages')
|
||||||
|
parser.add_argument('--description', type=str, required=True, help='Newsgroup topic summary')
|
||||||
|
parser.add_argument('--writable', action='store_true', help='Specify whether group is writable')
|
||||||
|
parser.add_argument('name', type=str, help='Name of newsgroup to create')
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.created_on is None:
|
||||||
|
args.created_on = datetime.datetime.now(datetime.UTC).isoformat()
|
||||||
|
|
||||||
|
config = Config.load(args.config_file)
|
||||||
|
db = Database.from_config(config)
|
||||||
|
|
||||||
|
newsgroup = Newsgroup()
|
||||||
|
newsgroup.name = args.name
|
||||||
|
newsgroup.description = args.description
|
||||||
|
newsgroup.created_on = datetime.datetime.fromisoformat(args.created_on)
|
||||||
|
newsgroup.created_by = args.created_by
|
||||||
|
newsgroup.writable = args.writable or False
|
||||||
|
|
||||||
|
db.execute("begin transaction")
|
||||||
|
db.add(newsgroup)
|
||||||
|
db.commit()
|
Loading…
Add table
Reference in a new issue