Un module simple pour demander l'accord de l'utilisateur dans une CLI.

Overview

Demande de confirmation utilisateur pour CLI


Présentation

ask_lib est un module pour le langage Python proposant une seule fonction; ask(). Le but principal de cette fonction est de proposer un wrapper de la fonction input() pour demander la confirmation de l'utilisateur avant de réaliser une action. ask_lib est donc particulièrement utile pour la création de CLI.

Exemple

import os

from ask_lib import AskResult, ask

reponse = ask("Êtes-vous sûr de vouloir supprimer ce fichier ?", AskResult.YES)
if reponse:
    try:
        os.remove("fichier.txt") # Supprime le fichier | A titre d'exemple
    except Exception:
        print("Quelque chose s'est mal passé...")
    else:
        print("Le fichier vient d'être supprimé.")
else:
    print("Le fichier n'a pas été supprimé.") 

Point de vu de l'utilisateur ;

Êtes-vous sûr de vouloir supprimer ce fichier ? [Y/n] n
Le fichier n'a pas été supprimé.
Êtes-vous sûr de vouloir supprimer ce fichier ? [Y/n] y
Le fichier vient d'être supprimé.

Particularités

  • ask_lib est entièrement documenté avec des docstrings riches et claires.
  • ask_lib est conforme aux principes de SOLID. Le principe de responsabilité unique y est totalement respecté.
  • ask_lib est très simple d'implémentation et d'utilisation.

Prérequis

ask_lib est compatible avec les versions de Python 3 à partir de la version 3.6.

Installation

Vous pouvez installer ask_lib en utilisant pip, avec la commande suivante ;

pip install ask_lib

Documentation

Vous pouvez consulter la documentation en cliquant ICI.
Vous pouvez retrouver ask_lib sur PyPi en cliquant ICI.

Licence

ask_lib est disponible sous licence MIT.

Owner
CallMePixelMan
Tout a commencé avec le Big Bang.. Et puis y'a eu moi.
CallMePixelMan
A CLI for creating styled-components for React projects quickly

new-component Ian Cleary (iancleary) Description Welcome! This is a CLI for creating styled-components for React projects quickly. Note: I've rewrote

Ian Cleary (he/him/his) 1 Feb 15, 2022
A tool to manage the study of courses at the university.

todo-cli A tool to manage the study of courses at the university

Quentin 6 Aug 01, 2022
A simple yet powerful timer and time tracker from the command line.

Focus Phase Focus Phase (FP) is a simple yet powerful timer and time tracker. It is a command-line application written in Python and can be installed

Ammar Alyousfi 13 Jan 13, 2022
Wordle breaker: A CLI tool to help you solve Wordle

Wordle Breaker A CLI tool to help you solve Wordle I decided to code a solution

Alex 4 Apr 27, 2022
A simple command line virtual operating system, written in python

Virtual operating system A simple virtual operating system written in python. (Under development). Currently, the following commands are supported: Co

B.Jothin kumar 7 Nov 15, 2022
Yet another bash/zsh prompt script

Here we have yet another script for Git-aware customization of the command prompt in Bash and zsh. Unlike all the other scripts, I wrote this one, so

John T. Wodder II 5 Oct 13, 2021
ctree - command line christmas tree

ctree ctree - command line christmas tree It is small python script that prints a christmas tree in terminal. It is colourful and always gives you a d

15 Aug 15, 2022
🎈 A Mini CLI-based Operating System simulator

Mini OS Simulator Summary 🎈 A Mini CLI-based Operating System simulator, well, not really. It simulates a file system with songs and movies and stuff

Jaiyank S. 3 Feb 14, 2022
Python implementation of SSH file transfer across servers.

SSH Transfer Python implementation of SSH file transfer across servers. Requirements paramiko=2.7.2 Usage Config Preparation Configure some informatio

Zhe Kong 1 Nov 23, 2021
Colab-xterm allows you to open a terminal in a cell

colab-xterm Colab-xterm allows you to open a terminal in a cell. Usage Install package and load the extension !pip install git+https://github.com/popc

InfuseAI 194 Dec 29, 2022
A Python package for a basic CLI and GUI user interface

Organizer CLI Organizer CLI is a python command line tool that goes through a given directory and organizes all un-folder bound files into folders by

Caltech Library 12 Mar 25, 2022
Set of scripts & tools for converting between numbers and major system encoded words.

major-system-converter Set of scripts & tools for converting between numbers and major system encoded words. Uses phonetics instead of letters to conv

4 Aug 09, 2022
A user-friendly python CLI for Fmask 4.3 software (GERS Lab, UCONN).

pyFmask What is pyFmask pyFmask is a user-friendly python CLI for Fmask 4.3 software (GERS Lab, UCONN; https://github.com/GERSL/Fmask). Fmask (Zhu et

1 Jan 05, 2022
Joji convert a text to corresponding emoji if emoji is available

Joji Joji convert a text to corresponding emoji if emoji is available How it Works ? 1. There is a json file with emoji names as keys and correspondin

Gopikrishnan Sasikumar 28 Nov 26, 2022
Python Command Line Application (CLI) using Typer, SQLModel, Async-PostgrSQL, and FastAPI

pyflycli is a command-line interface application built with Typer that allows you to view flights above your location.

Kevin Zehnder 14 Oct 01, 2022
A simple command line tool written in python to manage a to-do list

A simple command line tool written in python to manage a to-do list Dependencies: python Commands: todolist (-a | --add) [(-p | --priority)] [(-l | --

edwloef 0 Nov 02, 2021
Doro is a CLI based pomodoro app and countdown timer application built using python.

Doro - CLI based pomodoro app Doro is a CLI based pomodoro app and countdown timer application built using python. Install $ pip install doro Usage Po

Suresh Kumar 14 May 23, 2022
Bad Apple printed out on the console with Python!

Bad Apple printed out on the console with Python!

CalvinLoke 186 Dec 01, 2022
Command line tool to keep track of your favorite playlists on YouTube and many other places.

Command line tool to keep track of your favorite playlists on YouTube and many other places.

Wolfgang Popp 144 Jan 05, 2023
This is my fetch, with ascii arts from neofetch and internet

deadfetch This is my fetch, with ascii arts from neofetch and internet Installation First what you need its python Fedora sudo dnf install python3 sud

DedSec 8 Jan 20, 2022