Skip to content

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.

Notifications You must be signed in to change notification settings

Manavalan2517/Cli-Pastes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages