# Path: gg/state.py
# def load_config(configfile, key):
#     # like read() but returning specifically the state for the current repo
#     key = f"{get_repo_name()}:_config:{key}"
#     return read(configfile)[key]
# 
# def update_config(configfile, **kwargs):
#     state = read(configfile)
#     for key, value in kwargs.items():
#         state[f"{get_repo_name()}:_config:{key}"] = value
#     write(configfile, state)
# 
# Path: gg/main.py
# DEFAULT_CONFIGFILE = os.path.expanduser("~/.gg.json")
# class Config:
#     def __init__(self):
# def cli(config, configfile, verbose):


import json
import click
from gg.state import load_config, update_config
from gg.main import cli, pass_config



@cli.command()
@click.option(
    "--push-to-origin",
    default="",
    help="Push to the origin instead of your fork (true or false)",
)
@click.option(
    "--toggle-fixes-message",
    is_flag=True,
    default=False,
    help="Enable or disable the 'fixes' functionality in commits",
)
@pass_config
def local_config(config, push_to_origin="", toggle_fixes_message=False):
    """Setting configuration options per repo name"""
    if push_to_origin:
        try:
            before = load_config(config.configfile, "push_to_origin")
            print(f"push_to_origin before: {before}")
        except KeyError:
            print("push_to_origin before: not set")
        new_value = json.loads(push_to_origin)
        update_config(config.configfile, push_to_origin=new_value)
        print(f"push_to_origin after: {new_value}")

    if toggle_fixes_message:
        try:

# Path: gg/state.py
# def load_config(configfile, key):
#     # like read() but returning specifically the state for the current repo
#     key = f"{get_repo_name()}:_config:{key}"
#     return read(configfile)[key]
# 
# def update_config(configfile, **kwargs):
#     state = read(configfile)
#     for key, value in kwargs.items():
#         state[f"{get_repo_name()}:_config:{key}"] = value
#     write(configfile, state)
# 
# Path: gg/main.py
# DEFAULT_CONFIGFILE = os.path.expanduser("~/.gg.json")
# class Config:
#     def __init__(self):
# def cli(config, configfile, verbose):


# Path: gg/builtins/local_config.py
import json
import click
from gg.state import load_config, update_config
from gg.main import cli, pass_config




@cli.command()
@click.option(
    "--push-to-origin",
    default="",
    help="Push to the origin instead of your fork (true or false)",
)
@click.option(
    "--toggle-fixes-message",
    is_flag=True,
    default=False,
    help="Enable or disable the 'fixes' functionality in commits",
)
@pass_config
def local_config(config, push_to_origin="", toggle_fixes_message=False):
    """Setting configuration options per repo name"""
    if push_to_origin:
        try:
            before = load_config(config.configfile, "push_to_origin")
            print(f"push_to_origin before: {before}")
        except KeyError:
            print("push_to_origin before: not set")
        new_value = json.loads(push_to_origin)
        update_config(config.configfile, push_to_origin=new_value)
        print(f"push_to_origin after: {new_value}")

    if toggle_fixes_message:
        try:

            before = load_config(config.configfile, "fixes_message")