Git Product home page Git Product logo

cli-pastes's Introduction

CLI - Paste

CLI.-.Pastes.mp4

It is Inspired from ( https://github.com/codemyst/pastemyst )

A simple Python script to create and manage text pastes.

Introduction

This script allows users to create, view, and manage text pastes. It provides a simple command-line interface for creating new pastes and viewing existing ones.

Commands Used:

  • create: Create a new paste.
  • view: View an existing paste.
  • exit: Exit the script.

Modules Used:

The script imports several modules including

  1. json -----------> for parsing and generating JSON data
  2. platform ------> to access underlying platform’s identifying data
  3. os --------------> for a portable way of using operating system dependent functionality
  4. rich.console-> enables rich text and beautiful formatting in the terminal
  5. rich.syntax--> allows syntax highlighting of code snippets
  6. questionary--> for creating interactive prompts and questionnaires
  7. pyperclip----> access to the clipboard for copying and pasting
  8. random-------> used for generating random numbers and selecting random elements
  9. string-------> provides a collection of string constants, useful for generating random strings

Working

  1. The script checks if a JSON file named 'UserData.json' exists.
  1. If it doesn't exist, it creates a new one and stores the user's operating system information in it.
  1. The script also defines a function 'update_json' that updates the user's data in a JSON file named 'data.json'.
  1. The script then enters a while loop that prompts the user to select an action: create, view, or exit.
  1. If the user selects 'create', the script prompts for confirmation, paste name, and checks the user's operating system.
  1. If the operating system is Windows, it creates an empty text file, opens it with notepad, reads the entered data, and stores it in a variable 'pdData'.
  1. The script then generates a unique ID and checks if it already exists in the 'data.json' file.
  1. If it doesn't exist, it updates the JSON file with the paste name, ID, and data, and removes the temporary text file.
  1. If the user selects 'view', the script prompts for an ID and checks if it exists in the 'data.json' file.
  1. If it exists, it prints the paste content using the rich.syntax module, prompts the user to copy the content to the clipboard, and copies it if requested.
  1. If the user selects 'exit', the script breaks out of the while loop and terminates.
  1. If an unknown command is entered, the script prints a message to try again.

cli-pastes's People

Contributors

manavalan2517 avatar

Stargazers

jist avatar Iman avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.