npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

string-content-sort-cli

v2.0.5

Published

a cli for the npm package: string-content-sort

Downloads

3

Readme

String Content Sort Cli

A feature rich text sorter that takes indentation into account

This is a CLI for the npm package string-content-sort.

This cli tool is a part of a bigger project called scopedsort. Documentation and examples are mainly held there.

Usage

Command usage: ssort [files..] [options]

Concatenates provided file(s) -> sorts -> writes to standard output. Provided files that are directories will be recursively read.

If no file is provided, reads from standard input.

For options use either -h for short help or -H|--help for long help with descriptions.

Quick copy-paste from -h:

OPTIONS: SORTERS
    You can only have one sorter at a time.

    -i, --case-insensitive
    -e, --natural-sort
    -n, --numerical-sort
    -f, --float-sort
    -l, --length-sort
    -M, --month-sort
    -D, --day-sort
    -x, --none-sort
    -z, --random-sort

OPTIONS: UNIVERSAL MODIFIERS
    These options will work on everything.

    -r, --recursive [number]
    -s, --reverse
    -u, --unique ['i']
    -m, --markdown

OPTIONS: ITEM SEARCH
        --regex <regex_value>
    -F, --field-separator <regex | string>
    -k, --use-sort-group <sort_group>
    -p, --use-matched-regex
    -o, --sort-order <sort_order>
    -a, --attach-non-matching-to-bottom

OPTIONS: SECTIONS
    --section-separator <regex | string>
    --section-starter <regex>
    --section-rejoiner <string>

OPTIONS: OTHER
    -c, --use-sort-comments
        --modify
    -y, --yes

Sort Comments

This is documented on the website, but it's one of the most important features, so I'll repeat an introduction here.

sort-comments are a way for this program to recognize a section to sort. This can help if you have a list that is constantly being updated, and you don’t want to have to keep manually sorting

Example:

// { sort-start --regex /['"]/ }
import react from 'react';
import express from 'express';
import isIsOdd from 'is-is-odd';
// { sort-end }

Read the actual documentation for more.

Completions

You can use the following code if you want bash completions. It's not reactive to valid options, so you will still get auto completions for invalid options.

If the completion word doesn't start with - then it will just use the default file completion.

_ssort_completions() {
    local generic_options="--case-insensitive --natural-sort --numerical-sort --float-sort --length-sort --month-sort --day-sort --none-sort --random-sort --recursive --reverse --unique --markdown --regex --field-separator --use-sort-group --use-matched-regex --sort-order --attach-non-matching-to-bottom --section-separator --section-starter --section-rejoiner --use-sort-comments --modify --yes"

    local cur_word="${COMP_WORDS[COMP_CWORD]}"
    local prev_word="${COMP_WORDS[COMP_CWORD - 1]}"

    if [[ $cur_word = -* ]]; then
        COMPREPLY=( $(compgen -W "$generic_options" -- $cur_word))
    fi

    return 0
}

complete -F _ssort_completions -o default ssort

Questions & Contribution

This program might have some learning curve, so if you need any help, submit a GitHub issue, and I'll be glad to help. If you find any bugs or want to contribute also create a GitHub issue.