Esempio n. 1
0
def main(name):
    click.echo(f'Welcom scripter, developer, programmer and automater {name}')
    config = fs.read_config()
        
    if config['cli_dir'] == None:
        while True:
            cli_path = click.prompt('Enter the path/to/proj_creator map')
            if os.path.exists(cli_path):
                click.secho(('Path added to config file, for any path changes see yanr global_confi --help'), fg=const.CMD_CLR)
                fs.update_configFile('cli_dir', cli_path)
                break
            else:
                click.secho((f'Directory {cli_path} don t exist'), fg=const.ERROR_CLR, bold=True)
    else:
        pass
Esempio n. 2
0
def terminate_proces():
    """
    set project_dir, current_project_dir and yanr_init to null when project added succesfully to git,
    then yanr can be reused to create another project
    """

    config = fs.read_config()
    fs.update_configFile('current_project_dir', None)
    fs.update_configFile('project_name', None)
    fs.update_configFile('yanr_init', False)
Esempio n. 3
0
def global_config(username, password, projectdir):
    """
    Set your Github username, password  the directory where you want your projects to be stored as default
    so you don't have to do it anytime you create a new project. 
    """
    config = fs.read_config()
    if username != None and password != None and projectdir != None:
        fs.update_configFile('username', username)
        fs.update_configFile('password', password)
        fs.update_configFile('project_dir', projectdir)
    else:
        click.secho(('None of the option is given, see'), fg=const.INFO_CLR)
        click.secho(('yanr global_config --help'), fg=const.CMD_CLR)
        click.secho(('for more information'), fg=const.INFO_CLR)
Esempio n. 4
0
def create(ctx, proj_name, path, operatingsys):
    """
    \b
    create cmd optional arguments:
    \b
    -dj (create a django base project):
        # --packages, -p   : Install additional packages (max=2). See also yanr packages --help for more information about packages install
        
        # --req, -rq       : (default=requirements.txt)  pip freeze all your dependenties in a txt file, the default is requirements.txt, specify this option when you want another name. 
        
        # --frontend, -fr  : (default=False)  Install vue.js as frontend framework in django project if it is specify.  
        
        # --drestapi, -dra : Initialize the django project with a given restfull api framework.
    \b  
    -vue (create a vue.js base project):
        # No optional option
    \b
    -scrp (create a simple python scripting project):
        # No optional option
    """

    ctx.ensure_object(dict)  #send data to nested command
    config = fs.read_config()
    ctx.obj['operatingsys'] = operatingsys
    if config['yanr_init']:
        click.secho(
            ('The {} project is already initialized but not yet added to Git'.
             format(config['project_name'])),
            fg=const.INFO_CLR,
            bg='white')
        click.secho(('yanr git_repo --help for more information'.format(
            config['project_name'])),
                    fg=const.CMD_CLR)
        click.secho((
            'Or you have to terminate the ongoing proces to be able to create a new project.'
        ),
                    fg=const.INFO_CLR,
                    bg='white')
        click.secho(('yanr terminate --help for more information'),
                    fg=const.CMD_CLR)
        # user_input = click.prompt('Are you sure you don t want to add the current project to Git? [y/N]:')
        # if user_input == 'y':
        #     os.chdir(os.path.join(config['cli_dir'], const.CLI_NAME))
        #     terminate_proces()
        # elif user_input == 'N':
        #     sys.exit('See yanr git_repo --help for more detail')
        # else:
        #     click.secho(('Command don t exist'), fg=const.ERROR_CLR, bold=True)
        sys.exit()
    else:
        if path == None and config['project_dir'] == None:
            path = click.prompt(
                'Enter the path to the directory where you want the project to be stored'
            )
            fs.store_dataIn_configFile(ctx, path, proj_name)
            default_path = click.prompt(
                'Do you wanna use this path als defalt project path?[y/N')
            if default_path == 'y':
                fs.update_configFile('project_dir', path)
            else:
                pass
        elif config['project_dir'] != None:
            fs.store_dataIn_configFile(ctx, config['project_dir'], proj_name)
        elif path != None:
            fs.store_dataIn_configFile(ctx, path, proj_name)