Fix CLI character creation
This commit is contained in:
parent
eb5c52ea85
commit
92e12ae83c
|
@ -1,3 +1,7 @@
|
||||||
|
# Standard library imports
|
||||||
|
import json
|
||||||
|
|
||||||
|
# Module imports
|
||||||
from amanuensis.cli.helpers import (
|
from amanuensis.cli.helpers import (
|
||||||
add_argument, no_argument, requires_lexicon, requires_user, alias,
|
add_argument, no_argument, requires_lexicon, requires_user, alias,
|
||||||
config_get, config_set, CONFIG_GET_ROOT_VALUE)
|
config_get, config_set, CONFIG_GET_ROOT_VALUE)
|
||||||
|
@ -199,7 +203,7 @@ def command_player_list(args):
|
||||||
|
|
||||||
@alias('lcc')
|
@alias('lcc')
|
||||||
@requires_lexicon
|
@requires_lexicon
|
||||||
# @requires_username
|
@requires_user
|
||||||
@add_argument("--charname", required=True, help="The character's name")
|
@add_argument("--charname", required=True, help="The character's name")
|
||||||
def command_char_create(args):
|
def command_char_create(args):
|
||||||
"""
|
"""
|
||||||
|
@ -214,18 +218,17 @@ def command_char_create(args):
|
||||||
from amanuensis.user import UserModel
|
from amanuensis.user import UserModel
|
||||||
|
|
||||||
# Verify arguments
|
# Verify arguments
|
||||||
u = UserModel.by(name=args.username)
|
if args.user.id not in args.lexicon.join.joined:
|
||||||
if u is None:
|
logger.error('"{0.username}" is not a player in lexicon "{1.name}"'
|
||||||
logger.error("Could not find user '{}'".format(args.username))
|
''.format(args.user, args.lexicon))
|
||||||
return -1
|
return -1
|
||||||
lex = LexiconModel.by(name=args.lexicon)
|
|
||||||
if lex is None:
|
|
||||||
logger.error("Could not find lexicon '{}'".format(args.lexicon))
|
|
||||||
return -1
|
|
||||||
# u in lx TODO
|
|
||||||
|
|
||||||
# Internal call
|
# Perform command
|
||||||
add_character(lex, u, {"name": args.charname})
|
add_character(args.lexicon, args.user, {"name": args.charname})
|
||||||
|
|
||||||
|
# Output
|
||||||
|
logger.info('Created character "{0.charname}" for "{0.user.username}" in '
|
||||||
|
'"{0.lexicon.name}"'.format(args))
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Standard imports
|
# Standard library imports
|
||||||
import getpass
|
import getpass
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
|
|
@ -8,18 +8,20 @@
|
||||||
Created: {{ g.lexicon.time.created|asdate }}<br>
|
Created: {{ g.lexicon.time.created|asdate }}<br>
|
||||||
Completed: {{ g.lexicon.time.completed|asdate }}<br>
|
Completed: {{ g.lexicon.time.completed|asdate }}<br>
|
||||||
Players:
|
Players:
|
||||||
{% for uid in g.lexicon.join.joined[:-1] %}
|
{% for uid in g.lexicon.join.joined %}
|
||||||
{{ uid|user_attr('username') }},
|
{{ uid|user_attr('username') }}{% if not loop.last %},{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}<br>
|
||||||
{{ g.lexicon.join.joined[-1]|user_attr('username') }}<br>
|
Characters:
|
||||||
Log:
|
{% for char in g.lexicon.character.values() %}
|
||||||
<div style="width: 100%; height: 10em; overflow-y:auto; resize: vertical;
|
{{ char.name }} ({{ char.player|user_attr('username') }}){% if not loop.last %},{% endif %}
|
||||||
border: 1px solid #bbbbbb; font-size: 0.9em; padding:3px; box-sizing: border-box;">
|
{% endfor %}<br>
|
||||||
{% for log_entry in g.lexicon.log %}
|
|
||||||
[{{ log_entry[0]|asdate }}] {{ log_entry[1] }}<br>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
</p>
|
</p>
|
||||||
|
<div style="width: 100%; height: 10em; overflow-y:auto; resize: vertical;
|
||||||
|
border: 1px solid #bbbbbb; font-size: 0.9em; padding:3px; box-sizing: border-box;">
|
||||||
|
{% for log_entry in g.lexicon.log %}
|
||||||
|
[{{ log_entry[0]|asdate }}] {{ log_entry[1] }}<br>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% macro number_setting(field) %}
|
{% macro number_setting(field) %}
|
||||||
|
|
Loading…
Reference in New Issue